diff --git a/spec/locale.html b/spec/locale.html index 08351c22..a180f6e3 100644 --- a/spec/locale.html +++ b/spec/locale.html @@ -18,7 +18,7 @@

Intl.Locale ( _tag_ [ , _options_ ] )

1. If NewTarget is *undefined*, throw a *TypeError* exception. 1. Let _localeExtensionKeys_ be %Intl.Locale%.[[LocaleExtensionKeys]]. - 1. Let _internalSlotsList_ be « [[InitializedLocale]], [[Locale]], [[Calendar]], [[Collation]], [[HourCycle]], [[NumberingSystem]] ». + 1. Let _internalSlotsList_ be « [[InitializedLocale]], [[Locale]], [[Calendar]], [[Collation]], [[FirstDayOfWeek]], [[HourCycle]], [[NumberingSystem]] ». 1. If _localeExtensionKeys_ contains *"kf"*, then 1. Append [[CaseFirst]] to _internalSlotsList_. 1. If _localeExtensionKeys_ contains *"kn"*, then @@ -42,6 +42,11 @@

Intl.Locale ( _tag_ [ , _options_ ] )

1. If _collation_ is not *undefined*, then 1. If _collation_ cannot be matched by the type Unicode locale nonterminal, throw a *RangeError* exception. 1. Set _opt_.[[co]] to _collation_. + 1. Let _fw_ be ? GetOption(_options_, *"firstDayOfWeek"*, ~string~, ~empty~, *undefined*). + 1. If _fw_ is not *undefined*, then + 1. Set _fw_ to WeekdayToString(_fw_). + 1. If _fw_ cannot be matched by the type Unicode locale nonterminal, throw a *RangeError* exception. + 1. Set _opt_.[[fw]] to _fw_. 1. Let _hc_ be ? GetOption(_options_, *"hourCycle"*, ~string~, « *"h11"*, *"h12"*, *"h23"*, *"h24"* », *undefined*). 1. Set _opt_.[[hc]] to _hc_. 1. Let _kf_ be ? GetOption(_options_, *"caseFirst"*, ~string~, « *"upper"*, *"lower"*, *"false"* », *undefined*). @@ -57,6 +62,7 @@

Intl.Locale ( _tag_ [ , _options_ ] )

1. Set _locale_.[[Locale]] to _r_.[[locale]]. 1. Set _locale_.[[Calendar]] to _r_.[[ca]]. 1. Set _locale_.[[Collation]] to _r_.[[co]]. + 1. Set _locale_.[[FirstDayOfWeek]] to _r_.[[fw]]. 1. Set _locale_.[[HourCycle]] to _r_.[[hc]]. 1. If _localeExtensionKeys_ contains *"kf"*, then 1. Set _locale_.[[CaseFirst]] to _r_.[[kf]]. @@ -172,7 +178,7 @@

Intl.Locale.prototype

Internal slots

- The value of the [[LocaleExtensionKeys]] internal slot is « *"ca"*, *"co"*, *"hc"*, *"kf"*, *"kn"*, *"nu"* ». If %Intl.Collator%.[[RelevantExtensionKeys]] does not contain *"kf"*, then remove *"kf"* from %Intl.Locale%.[[LocaleExtensionKeys]]. If %Intl.Collator%.[[RelevantExtensionKeys]] does not contain *"kn"*, then remove *"kn"* from %Intl.Locale%.[[LocaleExtensionKeys]]. + The value of the [[LocaleExtensionKeys]] internal slot is « *"ca"*, *"co"*, *"fw"*, *"hc"*, *"kf"*, *"kn"*, *"nu"* ». If %Intl.Collator%.[[RelevantExtensionKeys]] does not contain *"kf"*, then remove *"kf"* from %Intl.Locale%.[[LocaleExtensionKeys]]. If %Intl.Collator%.[[RelevantExtensionKeys]] does not contain *"kn"*, then remove *"kn"* from %Intl.Locale%.[[LocaleExtensionKeys]].

@@ -277,6 +283,16 @@

get Intl.Locale.prototype.collation

+ +

get Intl.Locale.prototype.firstDayOfWeek

+

`Intl.Locale.prototype.firstDayOfWeek` is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:

+ + 1. Let _loc_ be the *this* value. + 1. Perform ? RequireInternalSlot(_loc_, [[InitializedLocale]]). + 1. Return _loc_.[[FirstDayOfWeek]]. + +
+

get Intl.Locale.prototype.hourCycle

`Intl.Locale.prototype.hourCycle` is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:

@@ -337,6 +353,88 @@

get Intl.Locale.prototype.region

1. Return GetLocaleRegion(_loc_.[[Locale]]).
+ + +

Intl.Locale.prototype.getCalendars ( )

+

When the `getCalendars` method is called, the following steps are taken:

+ + 1. Let _loc_ be the *this* value. + 1. Perform ? RequireInternalSlot(_loc_, [[InitializedLocale]]). + 1. Return CalendarsOfLocale(_loc_). + +
+ + +

Intl.Locale.prototype.getCollations ( )

+

When the `getCollations` method is called, the following steps are taken:

+ + 1. Let _loc_ be the *this* value. + 1. Perform ? RequireInternalSlot(_loc_, [[InitializedLocale]]). + 1. Return CollationsOfLocale(_loc_). + +
+ + +

Intl.Locale.prototype.getHourCycles ( )

+

When the `getHourCycles` method is called, the following steps are taken:

+ + 1. Let _loc_ be the *this* value. + 1. Perform ? RequireInternalSlot(_loc_, [[InitializedLocale]]). + 1. Return HourCyclesOfLocale(_loc_). + +
+ + +

Intl.Locale.prototype.getNumberingSystems ( )

+

When the `getNumberingSystems` method is called, the following steps are taken:

+ + 1. Let _loc_ be the *this* value. + 1. Perform ? RequireInternalSlot(_loc_, [[InitializedLocale]]). + 1. Return NumberingSystemsOfLocale(_loc_). + +
+ + +

Intl.Locale.prototype.getTimeZones ( )

+

When the `getTimeZones` method is called, the following steps are taken:

+ + 1. Let _loc_ be the *this* value. + 1. Perform ? RequireInternalSlot(_loc_, [[InitializedLocale]]). + 1. Let _region_ be GetLocaleRegion(_loc_.[[Locale]]). + 1. If _region_ is *undefined*, return *undefined*. + 1. Return TimeZonesOfLocale(_loc_). + +
+ + +

Intl.Locale.prototype.getTextInfo ( )

+

When the `getTextInfo` method is called, the following steps are taken:

+ + 1. Let _loc_ be the *this* value. + 1. Perform ? RequireInternalSlot(_loc_, [[InitializedLocale]]). + 1. Let _info_ be OrdinaryObjectCreate(%Object.prototype%). + 1. Let _dir_ be CharacterDirectionOfLocale(_loc_). + 1. Perform ! CreateDataPropertyOrThrow(_info_, *"direction"*, _dir_). + 1. Return _info_. + +
+ + +

Intl.Locale.prototype.getWeekInfo ( )

+

When the `getWeekInfo` method is called, the following steps are taken:

+ + 1. Let _loc_ be the *this* value. + 1. Perform ? RequireInternalSlot(_loc_, [[InitializedLocale]]). + 1. Let _info_ be OrdinaryObjectCreate(%Object.prototype%). + 1. Let _wi_ be WeekInfoOfLocale(_loc_). + 1. Let _we_ be CreateArrayFromList(_wi_.[[Weekend]]). + 1. Perform ! CreateDataPropertyOrThrow(_info_, *"firstDay"*, _wi_.[[FirstDay]]). + 1. Perform ! CreateDataPropertyOrThrow(_info_, *"weekend"*, _we_). + 1. Perform ! CreateDataPropertyOrThrow(_info_, *"minimalDays"*, _wi_.[[MinimalDays]]). + 1. Return _info_. + +
+ @@ -358,6 +456,7 @@

Properties of Intl.Locale Instances

  • [[Locale]] is a String value with the language tag of the locale whose localization is used for formatting.
  • [[Calendar]] is a String value that is a syntactically valid type value as given in Unicode Technical Standard #35 Part 1 Core, Section 3.2 Unicode Locale Identifier, or is *undefined*.
  • [[Collation]] is a String value that is a syntactically valid type value as given in Unicode Technical Standard #35 Part 1 Core, Section 3.2 Unicode Locale Identifier, or is *undefined*.
  • +
  • [[FirstDayOfWeek]] is a String value that is a syntactically valid type value as given in Unicode Technical Standard #35 Part 1 Core, Section 3.2 Unicode Locale Identifier, or is *undefined*.
  • [[HourCycle]] is a String value that is a syntactically valid type value as given in Unicode Technical Standard #35 Part 1 Core, Section 3.2 Unicode Locale Identifier, or is *undefined*.
  • [[NumberingSystem]] is a String value that is a syntactically valid type value as given in Unicode Technical Standard #35 Part 1 Core, Section 3.2 Unicode Locale Identifier, or is *undefined*.
  • [[CaseFirst]] is a String value that is a syntactically valid type value as given in Unicode Technical Standard #35 Part 1 Core, Section 3.2 Unicode Locale Identifier, or is *undefined*. This internal slot only exists if the [[LocaleExtensionKeys]] internal slot of %Intl.Locale% contains *"kf"*.
  • @@ -447,5 +546,258 @@

    1. Return the substring of _variants_ from 1. + + +

    + CreateArrayFromListOrRestricted ( + _list_: a List of ECMAScript language values, + _restricted_: an ECMAScript language value*, + ): an Array +

    +
    +
    + + 1. If _restricted_ is not *undefined*, then + 1. Set _list_ to « _restricted_ ». + 1. Return CreateArrayFromList( _list_ ). + +
    + + +

    + CalendarsOfLocale ( + _loc_: an Intl.Locale, + ): an Array +

    +
    +
    + + 1. Let _restricted_ be _loc_.[[Calendar]]. + 1. Let _locale_ be _loc_.[[Locale]]. + 1. Let _list_ be a List of one or more unique calendar types in canonical form (), sorted in descending preference of those in common use for date and time formatting in _locale_. + 1. Return CreateArrayFromListOrRestricted( _list_, _restricted_ ). + +
    + + +

    + CollationsOfLocale ( + _loc_: an Intl.Locale, + ): an Array +

    +
    +
    + + 1. Let _restricted_ be _loc_.[[Collation]]. + 1. Let _locale_ be _loc_.[[Locale]]. + 1. Let _list_ be a List of one or more unique collation types in canonical form (), of those in common use for string comparison in _locale_. The values *"standard"* and *"search"* must be excluded from _list_. The list is sorted according to lexicographic code unit order. + 1. Return CreateArrayFromListOrRestricted( _list_, _restricted_ ). + +
    + + +

    + HourCyclesOfLocale ( + _loc_: an Intl.Locale, + ): an Array +

    +
    +
    + + 1. Let _restricted_ be _loc_.[[HourCycle]]. + 1. Let _locale_ be _loc_.[[Locale]]. + 1. Let _list_ be a List of one or more unique hour cycle identifiers, which must be lower case String values indicating either the 12-hour format (*"h11"*, *"h12"*) or the 24-hour format (*"h23"*, *"h24"*), sorted in descending preference of those in common use for date and time formatting in _locale_. + 1. Return CreateArrayFromListOrRestricted( _list_, _restricted_ ). + +
    + + +

    + NumberingSystemsOfLocale ( + _loc_: an Intl.Locale, + ): an Array +

    +
    +
    + + 1. Let _restricted_ be _loc_.[[NumberingSystem]]. + 1. Let _locale_ be _loc_.[[Locale]]. + 1. Let _list_ be a List of one or more unique numbering system identifiers in canonical form (), sorted in descending preference of those in common use for formatting numeric values in _locale_. + 1. Return CreateArrayFromListOrRestricted( _list_, _restricted_ ). + +
    + + +

    + TimeZonesOfLocale ( + _loc_: an Intl.Locale, + ): an Array +

    +
    +
    + + 1. Let _region_ be GetLocaleRegion(_loc_.[[Locale]]). + 1. Assert: _region_ is not *undefined*. + 1. Let _list_ be a List of unique canonical time zone identifiers, which must be String values indicating a canonical Zone name of the IANA Time Zone Database, of those in common use in _region_. The list is empty if no time zones are commonly used in _region_. The list is sorted according to lexicographic code unit order. + 1. Return CreateArrayFromList( _list_ ). + +
    + + +

    + CharacterDirectionOfLocale ( + _loc_: an Intl.Locale, + ): *"ltr"* or *"rtl"* +

    +
    +
    description
    +
    The following algorithm refers to Locale data specified in UTS 35's Layouts Elements.
    +
    + + 1. Let _locale_ be _loc_.[[Locale]]. + 1. If the default general ordering of characters (characterOrder) within a line in _locale_ is right-to-left, return *"rtl"*. + 1. Return *"ltr"*. + +
    + + +

    + WeekdayToString ( + _fw_: a String, + ): a String +

    +
    +
    + + 1. For each row of , except the header row, in table order, do + 1. Let _w_ be the name given in the Weekday column of the current row. + 1. Let _s_ be the name given in the String column of the current row. + 1. If _fw_ is equal to _w_, return _s_. + 1. Return _fw_. + + + + First Day String and Value + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    WeekdayStringValue
    *"0"**"sun"**7*𝔽
    *"1"**"mon"**1*𝔽
    *"2"**"tue"**2*𝔽
    *"3"**"wed"**3*𝔽
    *"4"**"thu"**4*𝔽
    *"5"**"fri"**5*𝔽
    *"6"**"sat"**6*𝔽
    *"7"**"sun"**7*𝔽
    +
    +
    + + +

    + StringToWeekdayValue ( + _fw_: a String, + ): an integral Number or *undefined* +

    +
    +
    + + 1. For each row of , except the header row, in table order, do + 1. Let _s_ be the name given in the String column of the current row. + 1. Let _v_ be the name given in the Value column of the current row. + 1. If _fw_ is equal to _s_, return _v_. + 1. Return *undefined*. + +
    + + +

    + WeekInfoOfLocale ( + _loc_: an Intl.Locale, + ): a Record +

    +
    +
    description
    +
    The following algorithm refers to Locale data specified in UTS 35's Week Elements.
    +
    + + 1. Let _locale_ be _loc_.[[Locale]]. + 1. Let _r_ be a Record whose fields are defined by , with values based on _locale_. + 1. Let _fws_ be _loc_.[[FirstDayOfWeek]]. + 1. Let _fw_ be StringToWeekdayValue(_fws_). + 1. If _fw_ is not *undefined*, then + 1. Set _r_.[[FirstDay]] to _fw_. + 1. Return _r_. + + + + The record's return values are determined by _locale_, in accordance with the specifications outlined in UTS 35's Week Data and First Day Overrides. + + + + WeekInfo Record Fields + + + + + + + + + + + + + + + + + + + + + + + +
    Field NameValueMeaning
    [[FirstDay]]Integral Number value between *1*𝔽 and *7*𝔽: *1*𝔽 specifies Monday; *2*𝔽 specifies Tuesday; *3*𝔽 specifies Wednesday; *4*𝔽 specifies Thursday; *5*𝔽 specifies Friday; *6*𝔽 specifies Saturday; and *7*𝔽 specifies Sunday.The weekday value indicating which day of the week is considered the 'first' day, for calendar purposes.
    [[Weekend]]A List of one or more integral Number values, in ascending order, between *1*𝔽 and *7*𝔽: *1*𝔽 specifies Monday; *2*𝔽 specifies Tuesday; *3*𝔽 specifies Wednesday; *4*𝔽 specifies Thursday; *5*𝔽 specifies Friday; *6*𝔽 specifies Saturday; and *7*𝔽 specifies Sunday.The list of weekday values indicating which days of the week are considered as part of the 'weekend', for calendar purposes. Notice that the number of days in the weekend are different in each locale and may not be contiguous.
    [[MinimalDays]]Integral Number value between *1*𝔽 and *7*𝔽.The minimal days required in the first week of a month or year, for calendar purposes.
    +
    +