From 2f002b2000bf8b908efb793767bcfd23620e06db Mon Sep 17 00:00:00 2001 From: Frank Yung-Fong Tang Date: Tue, 26 Sep 2023 20:38:43 -0700 Subject: [PATCH] Normative: Change the hourCycle default logic (#758) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 https://github.com/tc39/ecma402/issues/402 Co-authored-by: Shane F. Carr Co-authored-by: Ujjwal Sharma Co-authored-by: André Bargull --- spec/datetimeformat.html | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/spec/datetimeformat.html b/spec/datetimeformat.html index 00b59308..31c0245e 100644 --- a/spec/datetimeformat.html +++ b/spec/datetimeformat.html @@ -79,15 +79,14 @@

1. Set _dateTimeFormat_.[[NumberingSystem]] to _r_.[[nu]]. 1. Let _dataLocale_ be _r_.[[dataLocale]]. 1. Let _dataLocaleData_ be _localeData_.[[<_dataLocale_>]]. - 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 _dataLocaleData_.[[hourCycle12]]. 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 _dataLocaleData_.[[hourCycle24]]. 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*, set _hc_ to _dataLocaleData_.[[hourCycle]]. 1. Set _dateTimeFormat_.[[HourCycle]] to _hc_. 1. Let _timeZone_ be ? Get(_options_, *"timeZone"*). 1. If _timeZone_ is *undefined*, then @@ -257,6 +256,12 @@

Internal slots

  • [[LocaleData]].[[<_locale_>]].[[hourCycle]] must be a String value equal to *"h11"*, *"h12"*, *"h23"*, or *"h24"*.
  • +
  • + [[LocaleData]].[[<_locale_>]].[[hourCycle12]] must be a String value equal to *"h11"* or *"h12"*. +
  • +
  • + [[LocaleData]].[[<_locale_>]].[[hourCycle24]] must be a String value equal to *"h23"* or *"h24"*. +
  • [[LocaleData]].[[<_locale_>]] must have a [[formats]] field. This [[formats]] field must be a Record with [[<_calendar_>]] fields for all calendar values _calendar_. The value of this field must be a list of records, each of which has a subset of the fields shown in , where each field must have one of the values specified for the field in . Multiple records in a list may use the same subset of the fields as long as they have different values for the fields. The following subsets must be available for each locale: