Skip to content
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

Remove locales with explicit u-hc Unicode extension #3958

Merged
merged 1 commit into from
Mar 9, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,33 @@ info: |
c. If hc is null, set hc to dataLocaleData.[[hourCycle]].
27. Set dateTimeFormat.[[HourCycle]] to hc.

locale: [en, fr, it, ja, zh, ko, ar, hi, en-u-hc-h24]
locale: [en, fr, it, ja, zh, ko, ar, hi]
---*/

let locales = ["en", "fr", "it", "ja", "ja-u-hc-h11", "zh", "ko", "ar", "hi", "en-u-hc-h24"];
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 === "h12") {
assert.sameValue(new Intl.DateTimeFormat(locale, { hour: "numeric", hour12: true }).resolvedOptions().hourCycle, hcDefault);
for (let locale of locales) {
let hcDefault = new Intl.DateTimeFormat(locale, {hour: "numeric"}).resolvedOptions().hourCycle;
assert(
hcDefault === "h11" || hcDefault === "h12" || hcDefault === "h23" || hcDefault === "h24",
"hcDefault is one of [h11, h12, h23, h24]"
);

// 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");
}
let hour12 = new Intl.DateTimeFormat(locale, {hour: "numeric", hour12: true}).resolvedOptions().hourCycle;
assert(hour12 === "h11" || hour12 === "h12", "hour12 is one of [h11, h12]");

let hour24 = new Intl.DateTimeFormat(locale, {hour: "numeric", hour12: false}).resolvedOptions().hourCycle;
assert(hour24 === "h23" || hour24 === "h24", "hour24 is one of [h23, h24]");

// 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);
if (hcDefault === "h11" || hcDefault === "h12") {
assert.sameValue(hour12, hcDefault, "hour12 matches hcDefault");
} else {
assert.sameValue(hour24, hcDefault, "hour24 matches hcDefault");
}

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\"]");
});
// 24-hour clock uses the "h23" format in all locales.
assert.sameValue(hour24, "h23");

// 12-hour clock uses the "h12" format in all locales except "ja".
assert.sameValue(hour12, locale === "ja" ? "h11" : "h12");
}
Loading