Duration
Class: Duration
Defined in: packages/utils/src/duration.ts:21
Represents a time duration that defaults to seconds but supports composite strings.
Constructors
Constructor
new Duration(
value):Duration
Defined in: packages/utils/src/duration.ts:29
Create a Duration.
Parameters
value
string | number
Number of seconds or a string representing the duration.
Returns
Duration
Properties
_raw
protected_raw:string|number
Defined in: packages/utils/src/duration.ts:22
seconds
protectedseconds:number
Defined in: packages/utils/src/duration.ts:23
Methods
expired()
expired(
start):boolean
Defined in: packages/utils/src/duration.ts:64
Check whether the duration has elapsed since start.
If start is not provided, uses the start provided to the constructor.
Parameters
start
string | number | Date
Optional start reference time.
Returns
boolean
true if now - start >= duration; otherwise false.
toMs()
toMs():
number
Defined in: packages/utils/src/duration.ts:38
Convert the duration to milliseconds.
Returns
number
Duration in milliseconds.
toSeconds()
toSeconds():
number
Defined in: packages/utils/src/duration.ts:46
Convert the duration to seconds.
Returns
number
Duration in seconds.
valueOf()
valueOf():
number
Defined in: packages/utils/src/duration.ts:54
Primitive numeric representation used in arithmetic, returns milliseconds.
Returns
number
Duration in milliseconds.