Intl.DurationFormat.prototype.resolvedOptions()
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
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
. style
-
One of the strings
"long"
,"short"
,"narrow"
, or"digital"
identifying the duration formatting style used. years
-
One of the strings
"long"
,"short"
, or"narrow"
identifying the formatting style used for theyears
field. yearsDisplay
-
One of the strings
"auto"
or"always"
identifying when to display theyears
field. months
-
One of the strings
"long"
,"short"
,and "narrow"
identifying the formatting style used for themonths
field. monthsDisplay
-
One of the strings
"auto"
or"always"
identifying when to display themonths
field. weeks
-
One of the strings
"long"
,"short"
,and "narrow"
identifying the formatting style used for theweeks
field. weeksDisplay
-
One of the strings
"auto"
or"always"
identifying when to display theweeks
field. days
-
One of the strings
"long"
,"short"
, and"narrow"
identifying the formatting style used for thedays
field. daysDisplay
-
One of the strings
"auto"
or"always"
identifying when to display thedays
field. hours
-
One of the strings
"long"
,"short"
,"narrow"
,"2-digit"
, or"numeric"
identifying the formatting style used for thehours
field. hoursDisplay
-
One of the strings
"auto"
or"always"
identifying when to display thehours
field. minutes
-
One of the strings
"long"
,"short"
,"narrow"
,"2-digit"
, or"numeric"
identifying the formatting style used for theminutes
field. minutesDisplay
-
One of the strings
"auto"
or"always"
identifying when to display theminutes
field. seconds
-
One of the strings
"long"
,"short"
,"narrow"
,"2-digit"
, or"numeric"
identifying the formatting style used for theseconds
field. secondsDisplay
-
One of the strings
"auto"
or"always"
identifying when to display theseconds
field. milliseconds
-
One of the strings
"long"
,"short"
,"narrow"
, or"numeric"
identifying the formatting style used for themilliseconds
field. millisecondsDisplay
-
One of the strings
"auto"
or"always"
identifying when to display themillisecondsDisplay
field. microseconds
-
One of the strings
"long"
,"short"
,"narrow"
, or"numeric"
identifying the formatting style used for themicroseconds
field. microsecondsDisplay
-
One of the strings
"auto"
or"always"
identifying when to display themicrosecondsDisplay
field. nanoseconds
-
One of the strings
"long"
,"short"
,"narrow"
, or"numeric"
identifying the formatting style used for thenanoseconds
field. nanosecondsDisplay
-
One of the strings
"auto"
or"always"
identifying when to display thenanosecondsDisplay
field. 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.
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"
Specifications
Specification |
---|
Intl.DurationFormat # sec-Intl.DurationFormat.prototype.resolvedOptions |
Browser compatibility
BCD tables only load in the browser