1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 10:27:35 +00:00

LibUnicode: Do not generate data for "generic" calendars

This is not a calendar supported by ECMA-402, so let's not waste space
with its data.

Further, don't generate "gregorian" as a valid Unicode locale extension
keyword. It's an invalid type identifier, thus cannot be used in locales
such as "en-u-ca-gregorian".
This commit is contained in:
Timothy Flynn 2021-11-30 21:23:13 -05:00 committed by Linus Groh
parent f02ecc1da2
commit bf79c73158
3 changed files with 18 additions and 13 deletions

View file

@ -21,32 +21,27 @@ describe("correct behavior", () => {
const en = Intl.DateTimeFormat("en", { calendar: "gregory" });
expect(en.resolvedOptions().calendar).toBe("gregory");
const el = Intl.DateTimeFormat("el", { calendar: "generic" });
expect(el.resolvedOptions().calendar).toBe("generic");
const el = Intl.DateTimeFormat("el", { calendar: "gregory" });
expect(el.resolvedOptions().calendar).toBe("gregory");
});
test("calendar may be set by locale extension", () => {
const en = Intl.DateTimeFormat("en-u-ca-gregory");
expect(en.resolvedOptions().calendar).toBe("gregory");
const el = Intl.DateTimeFormat("el-u-ca-generic");
expect(el.resolvedOptions().calendar).toBe("generic");
const el = Intl.DateTimeFormat("el-u-ca-gregory");
expect(el.resolvedOptions().calendar).toBe("gregory");
});
test("calendar option overrides locale extension", () => {
const el = Intl.DateTimeFormat("el-u-ca-generic", { calendar: "gregory" });
const el = Intl.DateTimeFormat("el-u-ca-gregory", { calendar: "gregory" });
expect(el.resolvedOptions().calendar).toBe("gregory");
});
test("calendar option limited to known 'ca' values", () => {
["generic", "hello"].forEach(calendar => {
["gregory", "hello"].forEach(calendar => {
const en = Intl.DateTimeFormat("en", { calendar: calendar });
expect(en.resolvedOptions().calendar).toBe("generic");
});
["generic", "hello"].forEach(calendar => {
const en = Intl.DateTimeFormat(`en-u-ca-${calendar}`);
expect(en.resolvedOptions().calendar).toBe("generic");
expect(en.resolvedOptions().calendar).toBe("gregory");
});
});