# new DurationFmt(optionsnullable)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
Object
|
<nullable> |
options governing the way this date formatter instance works |
Methods
# format(components) → {IString}
Format a duration according to the format template of this formatter instance.
The components parameter should be an object that contains any or all of these numeric properties:
- year
- month
- week
- day
- hour
- minute
- second
When a property is left out of the components parameter or has a value of 0, it will not be formatted into the output string, except for times that include 0 minutes and 0 seconds.
This formatter will not ensure that numbers for each component property is within the valid range for that component. This allows you to format durations that are longer than normal range. For example, you could format a duration has being "33 hours" rather than "1 day, 9 hours".
Parameters:
Name | Type | Description |
---|---|---|
components |
Object
|
date/time components to be formatted into a duration string |
a string with the duration formatted according to the style and locale set up for this formatter instance. If the components parameter is empty or undefined, an empty string is returned.
# getLength() → {string}
Return the length that was used to construct this duration formatter object. If the length was not given as parameter to the constructor, this method returns the default length. Valid values are "short", "medium", "long", and "full".
length that this duration formatter was constructed with
string
# getLocale() → {Locale}
Return the locale that was used to construct this duration formatter object. If the locale was not given as parameter to the constructor, this method returns the default locale of the system.
locale that this duration formatter was constructed with
# getStyle() → {string}
Return the style that was used to construct this duration formatter object. Returns one of "text" or "clock".
style that this duration formatter was constructed with
string