This method returns true
if this duration is finite,
or `false otherwise.
Negates this
duration, by changing the sign.
Calculates the days described by the source Duration.
Calculates the hours described by the source Duration.
Calculates the microseconds described by the source Duration.
Calculates the milliseconds described by the source Duration.
Calculates the minutes described by the source Duration.
Calculates the nanoseconds described by the source Duration.
Calculates the seconds described by the source Duration.
Constructs a Duration
instance out of a value representing
days.
Constructs a Duration
instance out of a value representing
hours.
Constructs a Duration
instance out of a value representing
microseconds.
Constructs a Duration
instance out of a value representing
milliseconds.
Constructs a Duration
instance out of a value representing
minutes.
Constructs a Duration
instance out of a value representing
nanoseconds.
Wraps the argument in a Duration.millis
reference, in case it's
a number, otherwise returns the argument as is.
In Javascript code it is customary to express durations with numbers representing milliseconds and in functions it's good to still allow developers to do that because it's the standard convention.
Thus one can work with a union type like number | Duration
.
And in case a number
is given, then it is interpreted as
milliseconds.
Usage:
function delay(d: number | Duration, r: () => {}) {
const millis = Duration.of(d).toMillis()
return setTimeout(r, millis)
}
Constructs a Duration
instance out of a value representing
seconds.
Returns a zero length duration.
Generated using TypeDoc
A simple representation for time durations, based on TimeUnit.