Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editorial: Only set dtf.[[HourCycle]] once. #662

Merged
merged 4 commits into from
Mar 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 23 additions & 24 deletions spec/datetimeformat.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,45 +73,44 @@ <h1>InitializeDateTimeFormat ( _dateTimeFormat_, _locales_, _options_ )</h1>
1. Set _dateTimeFormat_.[[Locale]] to _r_.[[locale]].
1. Let _calendar_ be _r_.[[ca]].
1. Set _dateTimeFormat_.[[Calendar]] to _calendar_.
1. Set _dateTimeFormat_.[[HourCycle]] to _r_.[[hc]].
1. Set _dateTimeFormat_.[[NumberingSystem]] to _r_.[[nu]].
1. Let _dataLocale_ be _r_.[[dataLocale]].
1. Let _dataLocaleData_ be _localeData_.[[&lt;_dataLocale_&gt;]].
1. Let _hcDefault_ be _dataLocaleData_.[[hourCycle]].
1. If _r_.[[hc]] is *null*, then
1. Let _hc_ be _hcDefault_.
1. If _hour12_ is *true*, then
1. If _hcDefault_ is *"h11"* or *"h23"*, then
1. Let _hc_ be *"h11"*.
1. Else,
1. Let _hc_ be *"h12"*.
1. Else if _hour12_ is *false*, then
1. If _hcDefault_ is *"h11"* or *"h23"*, then
1. Let _hc_ be *"h23"*.
1. Else,
1. Let _hc_ be *"h24"*.
1. Else,
1. Let _hc_ be _r_.[[hc]].
1. Assert: _hour12_ is *undefined*.
1. Set _dateTimeFormat_.[[HourCycle]] to _hc_.
1. Let _formatOptions_ be a new Record.
1. Set _formatOptions_.[[hourCycle]] to _hc_.
1. Let _timeZone_ be ? Get(_options_, *"timeZone"*).
1. If _timeZone_ is *undefined*, then
1. Let _timeZone_ be DefaultTimeZone().
1. Set _timeZone_ to DefaultTimeZone().
1. Else,
1. Let _timeZone_ be ? ToString(_timeZone_).
1. Set _timeZone_ to ? ToString(_timeZone_).
1. If the result of IsValidTimeZoneName(_timeZone_) is *false*, then
1. Throw a *RangeError* exception.
1. Let _timeZone_ be CanonicalizeTimeZoneName(_timeZone_).
1. Set _timeZone_ to CanonicalizeTimeZoneName(_timeZone_).
1. Set _dateTimeFormat_.[[TimeZone]] to _timeZone_.
1. Let _formatOptions_ be a new Record.
1. For each row of <emu-xref href="#table-datetimeformat-components"></emu-xref>, except the header row, in table order, do
1. Let _prop_ be the name given in the Property column of the row.
1. If _prop_ is *"fractionalSecondDigits"*, then
1. Let _value_ be ? GetNumberOption(_options_, *"fractionalSecondDigits"*, 1, 3, *undefined*).
1. Else,
1. Let _value_ be ? GetOption(_options_, _prop_, *"string"*, &laquo; the strings given in the Values column of the row &raquo;, *undefined*).
1. Set _formatOptions_.[[&lt;_prop_&gt;]] to _value_.
1. Let _dataLocaleData_ be _localeData_.[[&lt;_dataLocale_&gt;]].
1. Let _hcDefault_ be _dataLocaleData_.[[hourCycle]].
1. Let _hc_ be _dateTimeFormat_.[[HourCycle]].
1. If _hc_ is *null*, then
1. Set _hc_ to _hcDefault_.
1. If _hour12_ is *true*, then
1. If _hcDefault_ is *"h11"* or *"h23"*, then
1. Set _hc_ to *"h11"*.
1. Else,
1. Set _hc_ to *"h12"*.
1. Else if _hour12_ is *false*, then
1. If _hcDefault_ is *"h11"* or *"h23"*, then
1. Set _hc_ to *"h23"*.
1. Else,
1. Set _hc_ to *"h24"*.
1. Else,
1. Assert: _hour12_ is *undefined*.
1. Set _dateTimeFormat_.[[HourCycle]] to _hc_.
1. Set _formatOptions_.[[hourCycle]] to _hc_.
1. Let _matcher_ be ? GetOption(_options_, *"formatMatcher"*, *"string"*, &laquo; *"basic"*, *"best fit"* &raquo;, *"best fit"*).
1. Let _dateStyle_ be ? GetOption(_options_, *"dateStyle"*, *"string"*, &laquo; *"full"*, *"long"*, *"medium"*, *"short"* &raquo;, *undefined*).
1. Set _dateTimeFormat_.[[DateStyle]] to _dateStyle_.
Expand Down