Duration
Class which represents a duration object. A duration consists of a magnitude and a unit.
{
unit : String,
magnitude : Number
}
Valid values are:
- "millisecond" - Milliseconds
- "second" - Seconds
- "minute" - Minutes
- "hour" - Hours
- "day" - Days
- "week" - Weeks
- "month" - Months
- "quarter" - Quarters
- "year"- Years
Properties
3
Properties
3Get/Set numeric magnitude value.
The milliseconds property is a read only property which returns the number of milliseconds in this Duration
Get/set duration unit to use with the current magnitude value. Valid values are:
- "millisecond" - Milliseconds
- "second" - Seconds
- "minute" - Minutes
- "hour" - Hours
- "day" - Days
- "week" - Weeks
- "month" - Months
- "quarter" - Quarters
- "year"- Years
Functions
7
Functions
7Lifecycle
Duration constructor.
| Parameter | Type | Description |
|---|---|---|
magnitude | Number | String | Duration magnitude value or a duration + magnitude string ('2h', '4d') |
unit | DurationUnit | Duration unit value |
Other
Returns a new Duration which is the sum of this Duration and the passed Duration. The returned Duration unit is the same as this Duration's unit.
| Parameter | Type | Description |
|---|---|---|
otherDuration | Duration |
Returns a new Duration which is the difference between this Duration and the passed Duration. The returned Duration unit is the same as this Duration's unit.
| Parameter | Type | Description |
|---|---|---|
otherDuration | Duration |
Converts the passed parameter converted to a Duration object if possible,
or null if null or undefined passed.
| Parameter | Type | Description |
|---|---|---|
source | Number | String | Object | Duration | The data to be converted into a Duration. |
Returns truthy value if this Duration equals the passed value.
| Parameter | Type | Description |
|---|---|---|
value | Duration |
Returns a readable localized representation of this Duration (e.g. 5 days).
| Parameter | Type | Description |
|---|---|---|
useAbbreviation | Boolean | Pass |
nbrDecimals | Boolean | The maximum number of decimals for comparison and displaying in the editor |
Typedefs
1
Typedefs
1Object describing a duration.
| Parameter | Type | Description |
|---|---|---|
magnitude | Number | The magnitude of the duration |
unit | DurationUnit | The unit of the duration |