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

LibJS: Format the era of ISO year 0 as BC

This is a normative change in the ECMA-402 spec. See:
2034315
This commit is contained in:
Timothy Flynn 2023-02-01 21:03:59 +00:00 committed by Linus Groh
parent f0312de7eb
commit bb4fda3b97
2 changed files with 13 additions and 2 deletions

View file

@ -161,6 +161,17 @@ describe("era", () => {
expect(ar.format(d1)).toBe(d.ar1);
});
});
test("Year 1 BC (ISO year 0)", () => {
let year1BC = new Date(Date.UTC(0));
year1BC.setUTCFullYear(0);
const en = new Intl.DateTimeFormat("en", { era: "short", timeZone: "UTC" });
expect(en.format(year1BC)).toBe("1/1/1 BC");
const ar = new Intl.DateTimeFormat("ar", { era: "short", timeZone: "UTC" });
expect(ar.format(year1BC)).toBe("١ ١ ١ ق.م");
});
});
describe("year", () => {