Skip to content

Commit

Permalink
squash me
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-allen authored and ptomato committed Oct 2, 2023
1 parent 5608c8b commit df5a8cf
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ locale: [en, fr, it, ja, zh, ko, ar, hi, en-u-hc-h24]
let locales = ["en", "fr", "it", "ja", "ja-u-hc-h11", "zh", "ko", "ar", "hi", "en-u-hc-h24"];

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

// no locale has "h24" as a default. see https://github.com/tc39/ecma402/pull/758#issue-1622377292
assert.sameValue(new Intl.DateTimeFormat(locale, {hour: "numeric", hour12: false}).resolvedOptions().hourCycle, "h23");
assert.sameValue(new Intl.DateTimeFormat(locale, { hour: "numeric", hour12: false}).resolvedOptions().hourCycle, "h23");
}

// however, "h24" can be set via locale extension.
if (hcDefault === "h23" || hcDefault === "h24") {
assert.sameValue(new Intl.DateTimeFormat(locale, {hour: "numeric", hour12: false}).resolvedOptions().hourCycle, hcDefault);
assert.sameValue(new Intl.DateTimeFormat(locale, { hour: "numeric", hour12: false}).resolvedOptions().hourCycle, hcDefault);
}


let hcHour12 = new Intl.DateTimeFormat(locale, {hour: "numeric", hour12: true}).resolvedOptions().hourCycle;
let hcHour12 = new Intl.DateTimeFormat(locale, { hour: "numeric", hour12: true}).resolvedOptions().hourCycle;
assert(hcHour12 === "h11" || hcHour12 === "h12", "Expected `hourCycle`: " + hcHour12 + " to be in [\"h11\", \"h12\"]");
});

0 comments on commit df5a8cf

Please sign in to comment.