toSecond method

num toSecond(
  1. TimeUnit unit
)

convert num from unit to seconds

Implementation

num toSecond(TimeUnit unit) {
  switch (unit) {
    case TimeUnit.nanosecond:
      return this / 1e+9;
    case TimeUnit.microsecond:
      return this / 1e+6;
    case TimeUnit.millisecond:
      return this / 1000;
    case TimeUnit.minute:
      return this * 60;
    case TimeUnit.hour:
      return this * 3600;
    case TimeUnit.day:
      return this * 86400;
    case TimeUnit.week:
      return this * 604800;
    case TimeUnit.month:
      return this * 2.628e+6;
    case TimeUnit.calendarYear:
      return this * 3.154e+7;
    case TimeUnit.decade:
      return this * 3.154e+8;
    case TimeUnit.century:
      return this * 3.154e+9;
    default:
      return this;
  }
}