Skip to content

Commit

Permalink
Normative: Change the hourCycle default logic
Browse files Browse the repository at this point in the history
While hour12 is either true or false, let hourCycle to be either 'h12' or 'h23' but not 'h11' nor 'h24'.

The current logic is not reasonable. We see no region in the CLDR use h11 nor h24 hour cycle as default. 
While we set a hour12: true on a 24 hour system region (which use 0:00 - 23:59), we should set to h12 instead of h11

Do not perform the starnge logic of setting default hourCycle based on both hour12 and the defaultHourCycle while hour12 is true or false. Instead, only depends on hour12 to set it to h12 or h23. 

Address #402
  • Loading branch information
FrankYFTang authored Mar 13, 2023
1 parent 51f4efb commit d39f03a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions spec/datetimeformat.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,16 @@ <h1>InitializeDateTimeFormat ( _dateTimeFormat_, _locales_, _options_ )</h1>
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 _hour12_ is *true*, then
1. If _hcDefault_ is *"h11"* or *"h23"*, let _hc_ be *"h11"*. Otherwise, let _hc_ be *"h12"*.
1. Let _hc_ be *"h12"*.
1. Else if _hour12_ is *false*, then
1. If _hcDefault_ is *"h11"* or *"h23"*, let _hc_ be *"h23"*. Otherwise, let _hc_ be *"h24"*.
1. Let _hc_ be *"h23"*.
1. Else,
1. Assert: _hour12_ is *undefined*.
1. Let _hc_ be _r_.[[hc]].
1. If _hc_ is *null*, set _hc_ to _hcDefault_.
1. If _hc_ is *null*, then
1. Let _hcDefault_ be _dataLocaleData_.[[hourCycle]].
1. Set _hc_ to _hcDefault_.
1. Set _dateTimeFormat_.[[HourCycle]] to _hc_.
1. Let _timeZone_ be ? Get(_options_, *"timeZone"*).
1. If _timeZone_ is *undefined*, then
Expand Down

0 comments on commit d39f03a

Please sign in to comment.