Squiggle logoSquiggle
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 NameExampleConvert Number to DurationConvert Duration to Number
Minute5minutesfromMinutes(number)toMinutes(duration)
Hour5hourfromHours(number)toHours(duration)
Day5daysfromDays(number)toDays(duration)
Year5yearsfromYears(number)toYears(duration)

Constructors

fromMinutes

Namespace optional
Signatures
Duration.fromMinutes(Number) => Duration
Examples
Duration.fromMinutes(5)

fromHours

Namespace optional
Signatures
Duration.fromHours(Number) => Duration
Examples
Duration.fromHours(5)

fromDays

Namespace optional
Signatures
Duration.fromDays(Number) => Duration
Examples
Duration.fromDays(5)

fromYears

Namespace optional
Signatures
Duration.fromYears(Number) => Duration
Examples
Duration.fromYears(5)

Conversions

toMinutes

Namespace optional
Signatures
Duration.toMinutes(Duration) => Number
Examples
Duration.toMinutes(5minutes)

toHours

Namespace optional
Signatures
Duration.toHours(Duration) => Number
Examples
Duration.toHours(5minutes)

toDays

Namespace optional
Signatures
Duration.toDays(Duration) => Number
Examples
Duration.toDays(5minutes)

toYears

Namespace optional
Signatures
Duration.toYears(Duration) => Number
Examples
Duration.toYears(5minutes)

Algebra

unaryMinus

unary: -
Namespace optional
Signatures
Duration.unaryMinus(Duration) => Duration
Examples
-5minutes

add

infix: +
Namespace optional
Signatures
Duration.add(Duration, Duration) => Duration
Examples
5minutes + 10minutes

subtract

infix: -
Namespace optional
Signatures
Duration.subtract(Duration, Duration) => Duration
Examples
5minutes - 10minutes

multiply

infix: *
Namespace optional
Signatures
Duration.multiply(Duration, Number) => Duration
Duration.multiply(Number, Duration) => Duration
Examples
5minutes * 10
10 * 5minutes

divide

infix: /
Namespace optional
Signatures
Duration.divide(Duration, Duration) => Number
Examples
5minutes / 2minutes

divide

infix: /
Namespace optional
Signatures
Duration.divide(Duration, Duration) => Number
Examples
5minutes / 2minutes

Comparison

smaller

infix: <
Namespace optional
Signatures
Duration.smaller(Duration, Duration) => Bool

larger

infix: >
Namespace optional
Signatures
Duration.larger(Duration, Duration) => Bool

smallerEq

infix: <=
Namespace optional
Signatures
Duration.smallerEq(Duration, Duration) => Bool

largerEq

infix: >=
Namespace optional
Signatures
Duration.largerEq(Duration, Duration) => Bool

On this page