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

LibJS: Add test case for locales which do not define day periods

Some locales do not define morning, night, etc. day period ranges.
TR-35 states they should fall back to the fixed day periods AM and PM.
Add a test case for the "as" locale, which is one such locale, to ensure
its AM/PM symbols are used.
This commit is contained in:
Timothy Flynn 2021-12-10 13:21:44 -05:00 committed by Linus Groh
parent 5bdee9e38a
commit 07c5419a82

View file

@ -229,9 +229,9 @@ describe("day", () => {
describe("dayPeriod", () => {
// prettier-ignore
const data = [
{ dayPeriod: "narrow", en0: "5 in the afternoon", en1: "7 in the morning", ar0: "٥ بعد الظهر", ar1: "٧ صباحًا" },
{ dayPeriod: "short", en0: "5 in the afternoon", en1: "7 in the morning", ar0: "٥ بعد الظهر", ar1: "٧ ص" },
{ dayPeriod: "long", en0: "5 in the afternoon", en1: "7 in the morning", ar0: "٥ بعد الظهر", ar1: "٧ صباحًا" },
{ dayPeriod: "narrow", en0: "5 in the afternoon", en1: "7 in the morning", ar0: "٥ بعد الظهر", ar1: "٧ صباحًا", as0: "অপৰাহ্ন ৫", as1: "পূৰ্বাহ্ন "},
{ dayPeriod: "short", en0: "5 in the afternoon", en1: "7 in the morning", ar0: "٥ بعد الظهر", ar1: "٧ ص", as0: "অপৰাহ্ন ৫", as1: "পূৰ্বাহ্ন "},
{ dayPeriod: "long", en0: "5 in the afternoon", en1: "7 in the morning", ar0: "٥ بعد الظهر", ar1: "٧ صباحًا", as0: "অপৰাহ্ন ৫", as1: "পূৰ্বাহ্ন "},
];
test("all", () => {
@ -251,6 +251,14 @@ describe("dayPeriod", () => {
});
expect(ar.format(d0)).toBe(d.ar0);
expect(ar.format(d1)).toBe(d.ar1);
const as = new Intl.DateTimeFormat("as", {
dayPeriod: d.dayPeriod,
hour: "numeric",
timeZone: "UTC",
});
expect(as.format(d0)).toBe(d.as0);
expect(as.format(d1)).toBe(d.as1);
});
});
});