The abstract operation InitializeRelativeTimeFormat accepts the arguments relativeTimeFormat (which must be an object), locales, and options. It initializes relativeTimeFormat as a RelativeTimeFormat object. It performas the following steps:
"localeMatcher"
, "string"
, «"lookup"
, "best fit"
», "best fit"
)."style"
, "string"
, «"long"
, "short"
, "narrow"
», "long"
)."useGrouping"
, "minimumIntegerDigits"
, "style"
, "cardinal"
).
When the
"second"
, "minute"
, "hour"
, "day"
, "week"
, "month"
, "quarter"
, "year"
, throw a RangeError exception."past"
."future"
.
The MakePartsList abstract operation is called with arguments parts, a pattern String, unit, a String, and value a String.
MakePartsList("AA{0}BB", "hour", "15") --< Output (List of Records): [ {type: 'literal', value: 'AA'}, {type: 'hour', value: '15'}, {type: 'literal', value: 'BB'}, ]
"length"
)."literal"
, [[Value]]: literal } as a new element of the list result."0"
."literal"
, [[Value]]: literal } as a new element of the list result.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 RelativeTimeFormat constructor is 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
The Intl.RelativeTimeFormat constructor has the following properties:
The value of
This property has the attributes { [[Writable]]:
When the
The value of the
The value of the [[AvailableLocales]] internal slot is implementation defined within the constraints described in
The value of the [[RelevantExtensionKeys]] internal slot is [].
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.The Intl.RelativeTimeFormat prototype object is itself an ordinary object. %RelativeTimeFormatPrototype% is not an Intl.RelativeTimeFormat instance and does not have an [[InitializedRelatimveTimeFormat]] internal slot or any of the other internal slots of Intl.RelativeTimeFormat instance objects.
In the following descriptions of functions that are properties or [[Get]] attributes of properties of
The initial value of
The initial value of the @@toStringTag property is the string value "Object"
.
This property has the attributes { [[Writable]]:
When the
When the
This function provides access to the locale and formatting options computed during initialization of the object.
The function returns a new object whose properties and attributes are set as if constructed by an object literal assigning to each of the following properties the value of the corresponding internal slot of this RelativeTimeFormat object (see
Intl.RelativeTimeFormat instances inherit properties from
Intl.RelativeTimeFormat instances and other objects that have been successfully initialized as a RelativeTimeFormat have [[InitializedIntlObject]] and [[InitializedRelativeTimeFormat]] internal slots whose values are
Objects that have been successfully initialized as a RelativeTimeFormat object also have several internal slots that are computed by the constructor:
"long"
, "short"
, or "narrow"
, identifying the relative time format style used.