The resolvedOptions()
method of Intl.DurationFormat instances returns a new object with properties reflecting the locale and date and time formatting options computed during initialization of this Intl.DurationFormat object.
Syntax
resolvedOptions()
Parameters
None.
Return value
A new object with properties reflecting the locale and date and time formatting options computed during the initialization of the given Intl.DateTimeFormat object.
Description
The resulting object has the following properties:
locale
- : The BCP 47 language tag for the locale used. If any Unicode extension values were requested in the input BCP 47 language tag that led to this locale, the key-value pairs that were requested and are supported for this locale are included in
locale
.
- : The BCP 47 language tag for the locale used. If any Unicode extension values were requested in the input BCP 47 language tag that led to this locale, the key-value pairs that were requested and are supported for this locale are included in
style
- : One of the strings
"long"
,"short"
,"narrow"
, or"digital"
identifying the duration formatting style used.
- : One of the strings
years
- : One of the strings
"long"
,"short"
, or"narrow"
identifying the formatting style used for theyears
field.
- : One of the strings
yearsDisplay
- : One of the strings
"auto"
or"always"
identifying when to display theyears
field.
- : One of the strings
months
- : One of the strings
"long"
,"short"
,and "narrow"
identifying the formatting style used for themonths
field.
- : One of the strings
monthsDisplay
- : One of the strings
"auto"
or"always"
identifying when to display themonths
field.
- : One of the strings
weeks
- : One of the strings
"long"
,"short"
,and "narrow"
identifying the formatting style used for theweeks
field.
- : One of the strings
weeksDisplay
- : One of the strings
"auto"
or"always"
identifying when to display theweeks
field.
- : One of the strings
days
- : One of the strings
"long"
,"short"
, and"narrow"
identifying the formatting style used for thedays
field.
- : One of the strings
daysDisplay
- : One of the strings
"auto"
or"always"
identifying when to display thedays
field.
- : One of the strings
hours
- : One of the strings
"long"
,"short"
,"narrow"
,"2-digit"
, or"numeric"
identifying the formatting style used for thehours
field.
- : One of the strings
hoursDisplay
- : One of the strings
"auto"
or"always"
identifying when to display thehours
field.
- : One of the strings
minutes
- : One of the strings
"long"
,"short"
,"narrow"
,"2-digit"
, or"numeric"
identifying the formatting style used for theminutes
field.
- : One of the strings
minutesDisplay
- : One of the strings
"auto"
or"always"
identifying when to display theminutes
field.
- : One of the strings
seconds
- : One of the strings
"long"
,"short"
,"narrow"
,"2-digit"
, or"numeric"
identifying the formatting style used for theseconds
field.
- : One of the strings
secondsDisplay
- : One of the strings
"auto"
or"always"
identifying when to display theseconds
field.
- : One of the strings
milliseconds
- : One of the strings
"long"
,"short"
,"narrow"
, or"numeric"
identifying the formatting style used for themilliseconds
field.
- : One of the strings
millisecondsDisplay
- : One of the strings
"auto"
or"always"
identifying when to display themillisecondsDisplay
field.
- : One of the strings
microseconds
- : One of the strings
"long"
,"short"
,"narrow"
, or"numeric"
identifying the formatting style used for themicroseconds
field.
- : One of the strings
microsecondsDisplay
- : One of the strings
"auto"
or"always"
identifying when to display themicrosecondsDisplay
field.
- : One of the strings
nanoseconds
- : One of the strings
"long"
,"short"
,"narrow"
, or"numeric"
identifying the formatting style used for thenanoseconds
field.
- : One of the strings
nanosecondsDisplay
- : One of the strings
"auto"
or"always"
identifying when to display thenanosecondsDisplay
field.
- : One of the strings
fractionalDigits
- : A number, identifying the number of fractional digits used with numeric styles.
numberingSystem
- : The value provided for this property in the options argument, if present, or the value requested using the Unicode extension key
nu
or filled in as a default.
- : The value provided for this property in the options argument, if present, or the value requested using the Unicode extension key
Examples
Using the resolvedOptions method
const duration = new Intl.DurationFormat("en");
const usedOptions = duration.resolvedOptions();
usedOptions.locale; // "en"
usedOptions.numberingSystem; // "latn"
usedOptions.years; // "long"
usedOptions.yearsDisplay; // "auto"
usedOptions.style; // "long"