Members
hours
Equivalent to total('hour').
milliseconds
Equivalent to total('millisecond').
minutes
Equivalent to total('minute').
seconds
Equivalent to total('second').
Methods
add(other)
Adds another Duration to this one and returns a new Duration.
Parameters:
| Name | Type | Description |
|---|---|---|
other |
A Duration or Duration-like object, like from() takes. |
Returns:
| Type | Description |
|---|---|
|
A new Duration. |
subtract(other)
Subtracts another Duration from this one and returns a new Duration.
Parameters:
| Name | Type | Description |
|---|---|---|
other |
A Duration or Duration-like object, like from() takes. |
Returns:
| Type | Description |
|---|---|
|
A new Duration. |
total()
Calculates the total number of units of type 'totalOf' that would
fit inside this duration. The tc39 options parameter is not supported.
totalOf()
Calculates the total number of units of type 'totalOf' that would fit inside this duration.
No longer part of the tc39 spec, superseded by total().
(static) compare()
Compare two Duration objects. Returns -1 if the first is less than the second, zero if they are equal, 1 if the first is greater than the second.
Unlike tc39, this version does not accept options for relativeTo.
(static) from()
Creates a Duration from a DurationLike, which is an object containing zero or more of the following: hours, seconds, minutes, millis.