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:35
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:25
Raw
seconds
protectedseconds:number
Defined in: packages/utils/src/duration.ts:29
Seconds
Methods
expired()
expired(
start):boolean
Defined in: packages/utils/src/duration.ts:70
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:44
Convert the duration to milliseconds.
Returns
number
Duration in milliseconds.
toSeconds()
toSeconds():
number
Defined in: packages/utils/src/duration.ts:52
Convert the duration to seconds.
Returns
number
Duration in seconds.
valueOf()
valueOf():
number
Defined in: packages/utils/src/duration.ts:60
Primitive numeric representation used in arithmetic, returns milliseconds.
Returns
number
Duration in milliseconds.