Skip to content

Editorial: Cleanup InitializeDateTimeFormat #673

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

Merged
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
27 changes: 10 additions & 17 deletions spec/datetimeformat.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,30 +71,21 @@ <h1>InitializeDateTimeFormat ( _dateTimeFormat_, _locales_, _options_ )</h1>
1. Let _localeData_ be %DateTimeFormat%.[[LocaleData]].
1. Let _r_ be ResolveLocale(%DateTimeFormat%.[[AvailableLocales]], _requestedLocales_, _opt_, %DateTimeFormat%.[[RelevantExtensionKeys]], _localeData_).
1. Set _dateTimeFormat_.[[Locale]] to _r_.[[locale]].
1. Set _calendar_ to _r_.[[ca]].
1. Set _dateTimeFormat_.[[Calendar]] to _calendar_.
1. Let _resolvedCalendar_ be _r_.[[ca]].
1. Set _dateTimeFormat_.[[Calendar]] to _resolvedCalendar_.
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. If _hcDefault_ is *"h11"* or *"h23"*, let _hc_ be *"h11"*. Otherwise, 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. If _hcDefault_ is *"h11"* or *"h23"*, let _hc_ be *"h23"*. Otherwise, let _hc_ be *"h24"*.
1. Else,
1. Let _hc_ be _r_.[[hc]].
1. Assert: _hour12_ is *undefined*.
1. Let _hc_ be _r_.[[hc]].
1. If _hc_ is *null*, set _hc_ to _hcDefault_.
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. Set _timeZone_ to ! DefaultTimeZone().
Expand All @@ -104,6 +95,8 @@ <h1>InitializeDateTimeFormat ( _dateTimeFormat_, _locales_, _options_ )</h1>
1. Throw a *RangeError* exception.
1. Set _timeZone_ to ! CanonicalizeTimeZoneName(_timeZone_).
1. Set _dateTimeFormat_.[[TimeZone]] to _timeZone_.
1. Let _formatOptions_ be a new Record.
1. Set _formatOptions_.[[hourCycle]] to _hc_.
1. Let _hasExplicitFormatComponents_ be *false*.
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.
Expand All @@ -123,10 +116,10 @@ <h1>InitializeDateTimeFormat ( _dateTimeFormat_, _locales_, _options_ )</h1>
1. If _dateStyle_ is not *undefined* or _timeStyle_ is not *undefined*, then
1. If _hasExplicitFormatComponents_ is *true*, then
1. Throw a *TypeError* exception.
1. Let _styles_ be _dataLocaleData_.[[styles]].[[&lt;_calendar_&gt;]].
1. Let _styles_ be _dataLocaleData_.[[styles]].[[&lt;_resolvedCalendar_&gt;]].
1. Let _bestFormat_ be DateTimeStyleFormat(_dateStyle_, _timeStyle_, _styles_).
1. Else,
1. Let _formats_ be _dataLocaleData_.[[formats]].[[&lt;_calendar_&gt;]].
1. Let _formats_ be _dataLocaleData_.[[formats]].[[&lt;_resolvedCalendar_&gt;]].
1. If _matcher_ is *"basic"*, then
1. Let _bestFormat_ be BasicFormatMatcher(_formatOptions_, _formats_).
1. Else,
Expand Down