- Methods- add()
- as()
- asDays()
- asHours()
- asMilliseconds()
- asMinutes()
- asMonths()
- asQuarters()
- asSeconds()
- asWeeks()
- asYears()
- days()
- format()
- get()
- hours()
- humanize()
- humanizeIntl()
- isValid()
- locale()
- milliseconds()
- minutes()
- months()
- negate()
- normalize()
- quarters()
- rescale()
- seconds()
- set()
- shiftTo()
- subtract()
- toISOString()
- toJSON()
- toObject()
- weeks()
- years()
 
Defined in: src/typings/duration.ts:13
Methods
add()
add(
amount,unit?):Duration
Defined in: src/typings/duration.ts:69
Make this Duration longer by the specified amount. Return a newly-constructed Duration.
Parameters
| Parameter | Type | 
|---|---|
| amount | DurationInput | 
| unit? | DurationUnit | 
Returns
Duration
as()
as(
unit):number
Defined in: src/typings/duration.ts:15
Return the length of the duration in the specified unit.
Parameters
| Parameter | Type | 
|---|---|
| unit | DurationUnit | 
Returns
number
asDays()
asDays():
number
Defined in: src/typings/duration.ts:46
Return the length of the duration in the days.
Returns
number
asHours()
asHours():
number
Defined in: src/typings/duration.ts:41
Return the length of the duration in the hours.
Returns
number
asMilliseconds()
asMilliseconds():
number
Defined in: src/typings/duration.ts:26
Return the length of the duration in the milliseconds.
Returns
number
asMinutes()
asMinutes():
number
Defined in: src/typings/duration.ts:36
Return the length of the duration in the minutes.
Returns
number
asMonths()
asMonths():
number
Defined in: src/typings/duration.ts:56
Return the length of the duration in the months.
Returns
number
asQuarters()
asQuarters():
number
Defined in: src/typings/duration.ts:61
Return the length of the duration in the quarters.
Returns
number
asSeconds()
asSeconds():
number
Defined in: src/typings/duration.ts:31
Return the length of the duration in the seconds.
Returns
number
asWeeks()
asWeeks():
number
Defined in: src/typings/duration.ts:51
Return the length of the duration in the weeks.
Returns
number
asYears()
asYears():
number
Defined in: src/typings/duration.ts:66
Return the length of the duration in the years.
Returns
number
days()
days():
number
Defined in: src/typings/duration.ts:44
Get the days.
Returns
number
format()
format(
formatInput,options?):string
Defined in: src/typings/duration.ts:102
Returns a string representation of this Duration formatted according to the specified format string.
Used tokens are S for milliseconds, s for seconds, m for minutes, h for hours, d for days, w for weeks, M for months, and y for years.
Add padding by repeating the token, e.g. 'yy' pads the years to two digits, "hhhh" pads the hours to four digits.
Parameters
| Parameter | Type | 
|---|---|
| formatInput | string | 
| options? | FormatOptions | 
Returns
string
get()
get(
unit):number
Defined in: src/typings/duration.ts:18
Get the value of unit.
Parameters
| Parameter | Type | 
|---|---|
| unit | DurationUnit | 
Returns
number
hours()
hours():
number
Defined in: src/typings/duration.ts:39
Get the hours.
Returns
number
humanize()
humanize(
withSuffix?):string
Defined in: src/typings/duration.ts:90
Returns a string representation of a Duration in dateTime.from format.
Parameters
| Parameter | Type | 
|---|---|
| withSuffix? | boolean | 
Returns
string
humanizeIntl()
humanizeIntl(
options?):string
Defined in: src/typings/duration.ts:93
Returns a string representation of a Duration with all units included.
Parameters
| Parameter | Type | 
|---|---|
| options? | { listStyle?:"long"|"short"|"narrow";unitDisplay?:"long"|"short"|"narrow"; } | 
| options.listStyle? | "long"|"short"|"narrow" | 
| options.unitDisplay? | "long"|"short"|"narrow" | 
Returns
string
isValid()
isValid():
boolean
Defined in: src/typings/duration.ts:113
Returns
boolean
locale()
Call Signature
locale():
string
Defined in: src/typings/duration.ts:77
Returns
string
Call Signature
locale(
locale):Duration
Defined in: src/typings/duration.ts:78
Parameters
| Parameter | Type | 
|---|---|
| locale | string | 
Returns
Duration
milliseconds()
milliseconds():
number
Defined in: src/typings/duration.ts:24
Get the milliseconds.
Returns
number
minutes()
minutes():
number
Defined in: src/typings/duration.ts:34
Get the minutes.
Returns
number
months()
months():
number
Defined in: src/typings/duration.ts:54
Get the months.
Returns
number
negate()
negate():
Duration
Defined in: src/typings/duration.ts:75
Return the negative of this Duration.
Returns
Duration
normalize()
normalize(
options?):Duration
Defined in: src/typings/duration.ts:105
Reduce this Duration to its canonical representation in its current units.
Parameters
| Parameter | Type | 
|---|---|
| options? | { roundUp?:boolean; } | 
| options.roundUp? | boolean | 
Returns
Duration
quarters()
quarters():
number
Defined in: src/typings/duration.ts:59
Get the quarters.
Returns
number
rescale()
rescale(
options?):Duration
Defined in: src/typings/duration.ts:111
Rescale units to its largest representation
Parameters
| Parameter | Type | 
|---|---|
| options? | { roundUp?:boolean; } | 
| options.roundUp? | boolean | 
Returns
Duration
seconds()
seconds():
number
Defined in: src/typings/duration.ts:29
Get the seconds.
Returns
number
set()
set(
values):Duration
Defined in: src/typings/duration.ts:21
Set the values of specified units. Return a newly-constructed Duration.
Parameters
| Parameter | Type | 
|---|---|
| values | Partial | 
Returns
Duration
shiftTo()
shiftTo(
units,options?):Duration
Defined in: src/typings/duration.ts:108
Convert this Duration into its representation in a different set of units.
Parameters
| Parameter | Type | 
|---|---|
| units | DurationUnit[] | 
| options? | { roundUp?:boolean; } | 
| options.roundUp? | boolean | 
Returns
Duration
subtract()
subtract(
amount,unit?):Duration
Defined in: src/typings/duration.ts:72
Make this Duration shorter by the specified amount. Return a newly-constructed Duration.
Parameters
| Parameter | Type | 
|---|---|
| amount | DurationInput | 
| unit? | DurationUnit | 
Returns
Duration
toISOString()
toISOString():
string
Defined in: src/typings/duration.ts:81
Returns an ISO 8601-compliant string representation of this Duration.
Returns
string
toJSON()
toJSON():
string
Defined in: src/typings/duration.ts:84
Returns an ISO 8601 representation of this Duration appropriate for use in JSON.
Returns
string
toObject()
toObject():
Partial
Defined in: src/typings/duration.ts:87
Returns a JavaScript object with this Duration's values.
Returns
Partial
weeks()
weeks():
number
Defined in: src/typings/duration.ts:49
Get the weeks.
Returns
number
years()
years():
number
Defined in: src/typings/duration.ts:64
Get the years.
Returns
number