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

LibJS: Use locale-aware day period time ranges to format period symbols

For the test cases changed here, we now recognize "morning2" and
"afternoon2" from the CLDR, so the expected results now match the specs
and other engines.
This commit is contained in:
Timothy Flynn 2021-12-10 12:57:59 -05:00 committed by Linus Groh
parent a417c23de0
commit 5bdee9e38a
3 changed files with 7 additions and 24 deletions

View file

@ -228,12 +228,10 @@ describe("day", () => {
describe("dayPeriod", () => {
// prettier-ignore
// FIXME: The ar formats aren't entirely correct. LibUnicode is only parsing e.g. "morning1" in the "dayPeriods"
// CLDR object. It will need to parse "morning2", and figure out how to apply it.
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: "٧ صباحًا" },
{ 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: "٧ صباحًا" },
];
test("all", () => {

View file

@ -233,8 +233,6 @@ describe("special cases", () => {
{ type: "dayPeriod", value: "in the morning" },
]);
// FIXME: The ar format isn't entirely correct. LibUnicode is only parsing e.g. "morning1" in the "dayPeriods"
// CLDR object. It will need to parse "morning2", and figure out how to apply it.
const ar = new Intl.DateTimeFormat("ar", {
dayPeriod: "long",
hour: "numeric",
@ -243,7 +241,7 @@ describe("special cases", () => {
expect(ar.formatToParts(d)).toEqual([
{ type: "hour", value: "٧" },
{ type: "literal", value: " " },
{ type: "dayPeriod", value: "في الصباح" },
{ type: "dayPeriod", value: "صباحًا" },
]);
});