Skip to content

Commit

Permalink
Normative: Add calendar and numberingSystem options
Browse files Browse the repository at this point in the history
This patch allows calendar and numberingSystem to be specified in
the options bag of the DateTimeFormat and NumberFormat constructors.
One use case for these options would be, when working with locales
which have two numbering systems and calendars in use--the UA default
may be the non-Western one, but in some contexts, it may be appropriate
to use the Western one. Currently, without the patch, it would be
necessary to parse the BCP 47 language tag in the application, but Intl
provides no library to do so. For example, this all occurs in this bug:
https://bugzilla.mozilla.org/show_bug.cgi?id=1370086

Related bug: tc39#105 . This patch leaves out "collation" because of a lack
of clear use cases.
  • Loading branch information
littledan committed Sep 13, 2017
1 parent 67cbcb4 commit 01d962e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions spec/datetimeformat.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ <h1>InitializeDateTimeFormat ( _dateTimeFormat_, _locales_, _options_ )</h1>
1. Let _opt_ be a new Record.
1. Let _matcher_ be ? GetOption(_options_, *"localeMatcher"*, *"string"*, &laquo; *"lookup"*, *"best fit"* &raquo;, *"best fit"*).
1. Set _opt_.[[localeMatcher]] to _matcher_.
1. Let _calendar_ be ? Get(_options_, *"calendar"*).
1. If _calendar_ is not *undefined*, set _calendar_ to ? ToString(_calendar_).
1. Set _opt_.[[ca]] to _calendar_.
1. Let _numberingSystem_ be ? Get(_options_, *"numberingSystem"*).
1. If _numberingSystem_ is not *undefined*, set _numberingSystem_ to ? ToString(_numeringSystem_).
1. Set _opt_.[[nu]] to _numeringSystem_.
1. Let _hc_ be ? GetOption(_options_, *"hourCycle"*, *"string"*, &laquo; *"h11"*, *"h12"*, *"h23"*, *"h24"* &raquo;, *undefined*).
1. Set _opt_.[[hc]] to _hc_.
1. Let _localeData_ be %DateTimeFormat%.[[LocaleData]].
Expand Down
3 changes: 3 additions & 0 deletions spec/numberformat.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ <h1>InitializeNumberFormat ( _numberFormat_, _locales_, _options_ )</h1>
1. Let _opt_ be a new Record.
1. Let _matcher_ be ? GetOption(_options_, *"localeMatcher"*, *"string"*, &laquo; *"lookup"*, *"best fit"* &raquo;, *"best fit"*).
1. Set _opt_.[[localeMatcher]] to _matcher_.
1. Let _numberingSystem_ be ? Get(_options_, *"numberingSystem"*).
1. If _numberingSystem_ is not *undefined*, set _numberingSystem_ to ? ToString(_numeringSystem_).
1. Set _opt_.[[nu]] to _numeringSystem_.
1. Let _localeData_ be %NumberFormat%.[[LocaleData]].
1. Let _r_ be ResolveLocale(%NumberFormat%.[[AvailableLocales]], _requestedLocales_, _opt_, %NumberFormat%.[[RelevantExtensionKeys]], _localeData_).
1. Set _numberFormat_.[[Locale]] to _r_.[[locale]].
Expand Down

0 comments on commit 01d962e

Please sign in to comment.