Skip to content

Commit

Permalink
updated hourCycle-default.js to reflect new behaviour of hourCycle, w…
Browse files Browse the repository at this point in the history
…hich now associates h12 with h23 rather than h23 pr#758
  • Loading branch information
ben-allen committed Jul 26, 2023
1 parent 9437cab commit efd3b5c
Showing 1 changed file with 7 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ description: >
Intl.DateTimeFormat.prototype.resolvedOptions properly
reflect hourCycle settings.
info: |
12.4.5 Intl.DateTimeFormat.prototype.resolvedOptions()
12.1.1 InitializeDateTimeFormat ( dateTimeFormat, locales, options )
29. If dateTimeFormat.[[Hour]] is not undefined, then
Expand All @@ -34,23 +33,12 @@ locale: [en, fr, it, ja, zh, ko, ar, hi]

let locales = ["en", "fr", "it", "ja", "zh", "ko", "ar", "hi"];

locales.forEach(function(locale) {
let hcDefault = (new Intl.DateTimeFormat(locale, {hour: "numeric"}))
.resolvedOptions().hourCycle;
if (hcDefault == "h11" || hcDefault == "h23") {
assert.sameValue("h11",
(new Intl.DateTimeFormat(locale, {hour: "numeric", hour12: true}))
.resolvedOptions().hourCycle);
assert.sameValue("h23",
(new Intl.DateTimeFormat(locale, {hour: "numeric", hour12: false}))
.resolvedOptions().hourCycle);
} else {
assert.sameValue(true, hcDefault == "h12" || hcDefault == "h24")
assert.sameValue("h12",
(new Intl.DateTimeFormat(locale, {hour: "numeric", hour12: true}))
.resolvedOptions().hourCycle);
assert.sameValue("h24",
(new Intl.DateTimeFormat(locale, {hour: "numeric", hour12: false}))
.resolvedOptions().hourCycle);
locales.forEach(function(locale){
let hcDefault = new Intl.DateTimeFormat(locale, {hour: "numeric"}).resolvedOptions().hourCycle;
if (hcDefault === "h11" || hcDefault === "h12"){
assert.sameValue(hcDefault, new Intl.DateTimeFormat(locale, {hour: "numeric", hour12: true}).resolvedOptions().hourCycle);
}
if (hcDefault === "h23" || hcDefault === "h24"){
assert.sameValue(hcDefault, new Intl.DateTimeFormat(locale, {hour: "numeric", hour12: false}).resolvedOptions().hourCycle);
}
});

0 comments on commit efd3b5c

Please sign in to comment.