The abstract operation InitializeRelativeTimeFormat accepts the arguments relativeTimeFormat (which must be an object), locales, and options. It initializes relativeTimeFormat as a RelativeTimeFormat object.
The following steps are taken:
"localeMatcher"
, "string"
, «"lookup"
, "best fit"
», "best fit"
)."numberingSystem"
, "string"
, (3*8alphanum) *("-" (3*8alphanum))
sequence, throw a "style"
, "string"
, «"long"
, "short"
, "narrow"
», "long"
)."numeric"
, "string"
, «"always"
, "auto"
», "always"
)."seconds"
, return "second"
."minutes"
, return "minute"
."hours"
, return "hour"
."days"
, return "day"
."weeks"
, return "week"
."months"
, return "month"
."quarters"
, return "quarter"
."years"
, return "year"
."second"
, "minute"
, "hour"
, "day"
, "week"
, "month"
, "quarter"
, or "year"
, throw a
When the
"short"
, then"-short"
."narrow"
, then"-narrow"
."auto"
, then"past"
."future"
.
The MakePartsList abstract operation is called with arguments pattern, a pattern String, unit, a String, and parts, a
MakePartsList("AA{0}BB", "hour", « { [[Type]]: "integer", [[Value]]: "15" } » ) Output (List of Records): « { [[Type]]: "literal", [[Value]]: "AA"}, { [[Type]]: "integer", [[Value]]: "15", [[Unit]]: "hour"}, { [[Type]]: "literal", [[Value]]: "BB"} »
The FormatRelativeTime abstract operation is called with arguments relativeTimeFormat (which must be an object initialized as a RelativeTimeFormat), value (which must be a Number value), and unit (which must be a String denoting the value unit) and performs the following steps:
The FormatRelativeTimeToParts abstract operation is called with arguments relativeTimeFormat (which must be an object initialized as a RelativeTimeFormat), value (which must be a Number value), and unit (which must be a String denoting the value unit) and performs the following steps:
"type"
, part.[[Type]])."value"
, part.[[Value]])."unit"
, part.[[Unit]]).
The RelativeTimeFormat constructor is the %RelativeTimeFormat% intrinsic object and a standard built-in property of the Intl object. Behaviour common to all service constructor properties of the Intl object is specified in
When the
"%RelativeTimeFormatPrototype%"
, « [[InitializedRelativeTimeFormat]], [[Locale]], [[Style]], [[Numeric]], [[Fields]], [[NumberFormat]], [[NumberingSystem]], [[PluralRules]] »).The Intl.RelativeTimeFormat constructor has the following properties:
The value of Intl.RelativeTimeFormat.prototype
is
This property has the attributes { [[Writable]]:
When the supportedLocalesOf
method of
The value of the [[AvailableLocales]] internal slot is implementation defined within the constraints described in
The value of the [[RelevantExtensionKeys]] internal slot is « "nu"
».
The value of the [[LocaleData]] internal slot is implementation defined within the constraints described in
"second"
, "minute"
, "hour"
, "day"
, "week"
, "month"
, "quarter"
, and "year"
. Additional property keys may exist with the previous names concatenated with the strings "-narrow"
or "-short"
. The values corresponding to these property keys are objects which contain these two categories of properties:
"future"
and "past"
properties, which are objects with a property for each of the [[PluralCategories]] in the Locale. The value corresponding to those properties is a pattern which may contain "{0}"
to be replaced by a formatted number."nu"
field of any locale field of [[LocaleData]] must not include the values "native"
, "traditio"
, or "finance"
.
The Intl.RelativeTimeFormat prototype object is itself an ordinary object. %RelativeTimeFormatPrototype% is not an Intl.RelativeTimeFormat instance and does not have an [[InitializedRelativeTimeFormat]] internal slot or any of the other internal slots of Intl.RelativeTimeFormat instance objects.
The initial value of Intl.RelativeTimeFormat.prototype.constructor
is
The initial value of the @@toStringTag property is the string value "Intl.RelativeTimeFormat"
.
This property has the attributes { [[Writable]]:
When the format
method is called with arguments value and unit, the following steps are taken:
When the formatToParts
method is called with arguments value and unit, the following steps are taken:
This function provides access to the locale and options computed during initialization of the object.
Internal Slot | Property |
---|---|
[[Locale]] | "locale" |
[[Style]] | "style" |
[[Numeric]] | "numeric" |
[[NumberingSystem]] | "numberingSystem" |
Intl.RelativeTimeFormat instances are ordinary objects that inherit properties from
Intl.RelativeTimeFormat instances have an [[InitializedRelativeTimeFormat]] internal slot.
Intl.RelativeTimeFormat instances also have several internal slots that are computed by the constructor:
"long"
, "short"
, or "narrow"
, identifying the relative time format style used."always"
or "auto"
, identifying whether numerical descriptions are always used, or used only when no more specific version is available (e.g., "1 day ago" vs "yesterday")."type"
given in Unicode Technical Standard 35 for the numbering system used for formatting.