API
Duration
Durations are a simple time type, representing a length of time. They are internally stored as milliseconds, but often shown and written using seconds, minutes, hours, days, etc.
Durations are typically used with Date values.
Unit Name | Example | Convert Number to Duration | Convert Duration to Number |
---|---|---|---|
Minute | 5minutes | fromMinutes(number) | toMinutes(duration) |
Hour | 5hour | fromHours(number) | toHours(duration) |
Day | 5days | fromDays(number) | toDays(duration) |
Year | 5years | fromYears(number) | toYears(duration) |
Constructors
fromMinutes
Namespace optional
Duration.fromMinutes(Number) => Duration
Duration.fromMinutes(5)
fromHours
Namespace optional
Duration.fromHours(Number) => Duration
Duration.fromHours(5)
fromDays
Namespace optional
Duration.fromDays(Number) => Duration
Duration.fromDays(5)
fromYears
Namespace optional
Duration.fromYears(Number) => Duration
Duration.fromYears(5)
Conversions
toMinutes
Namespace optional
Duration.toMinutes(Duration) => Number
Duration.toMinutes(5minutes)
toHours
Namespace optional
Duration.toHours(Duration) => Number
Duration.toHours(5minutes)
toDays
Namespace optional
Duration.toDays(Duration) => Number
Duration.toDays(5minutes)
toYears
Namespace optional
Duration.toYears(Duration) => Number
Duration.toYears(5minutes)
Algebra
unaryMinus
unary: -
Namespace optional
Duration.unaryMinus(Duration) => Duration
-5minutes
add
infix: +
Namespace optional
Duration.add(Duration, Duration) => Duration
5minutes + 10minutes
subtract
infix: -
Namespace optional
Duration.subtract(Duration, Duration) => Duration
5minutes - 10minutes
multiply
infix: *
Namespace optional
Duration.multiply(Duration, Number) => Duration
Duration.multiply(Number, Duration) => Duration
5minutes * 10
10 * 5minutes
divide
infix: /
Namespace optional
Duration.divide(Duration, Duration) => Number
5minutes / 2minutes
divide
infix: /
Namespace optional
Duration.divide(Duration, Duration) => Number
5minutes / 2minutes
Comparison
smaller
infix: <
Namespace optional
Duration.smaller(Duration, Duration) => Bool
larger
infix: >
Namespace optional
Duration.larger(Duration, Duration) => Bool
smallerEq
infix: <=
Namespace optional
Duration.smallerEq(Duration, Duration) => Bool
largerEq
infix: >=
Namespace optional
Duration.largerEq(Duration, Duration) => Bool