mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 08:37:46 +00:00
LibJS: Correctly resolve locale hour cycles in Intl.DateTimeFormat
This is a normative change in the ECMA-402 spec. See:
2f002b2
This commit is contained in:
parent
39be5cb73a
commit
05e080c4ba
2 changed files with 75 additions and 50 deletions
|
@ -85,6 +85,32 @@ describe("correct behavior", () => {
|
|||
});
|
||||
});
|
||||
|
||||
test("hour12", () => {
|
||||
const en1 = Intl.DateTimeFormat("en", { hour: "numeric" });
|
||||
expect(en1.resolvedOptions().hourCycle).toBe("h12");
|
||||
expect(en1.resolvedOptions().hour12).toBeTrue();
|
||||
|
||||
const en2 = Intl.DateTimeFormat("en", { hour: "numeric", hour12: true });
|
||||
expect(en2.resolvedOptions().hourCycle).toBe("h12");
|
||||
expect(en2.resolvedOptions().hour12).toBeTrue();
|
||||
|
||||
const en3 = Intl.DateTimeFormat("en", { hour: "numeric", hour12: false });
|
||||
expect(en3.resolvedOptions().hourCycle).toBe("h23");
|
||||
expect(en3.resolvedOptions().hour12).toBeFalse();
|
||||
|
||||
const ja1 = Intl.DateTimeFormat("ja", { hour: "numeric" });
|
||||
expect(ja1.resolvedOptions().hourCycle).toBe("h23");
|
||||
expect(ja1.resolvedOptions().hour12).toBeFalse();
|
||||
|
||||
const ja2 = Intl.DateTimeFormat("ja", { hour: "numeric", hour12: true });
|
||||
expect(ja2.resolvedOptions().hourCycle).toBe("h11");
|
||||
expect(ja2.resolvedOptions().hour12).toBeTrue();
|
||||
|
||||
const ja3 = Intl.DateTimeFormat("ja", { hour: "numeric", hour12: false });
|
||||
expect(ja3.resolvedOptions().hourCycle).toBe("h23");
|
||||
expect(ja3.resolvedOptions().hour12).toBeFalse();
|
||||
});
|
||||
|
||||
test("timeZone", () => {
|
||||
const en = new Intl.DateTimeFormat("en", { timeZone: "EST" });
|
||||
expect(en.resolvedOptions().timeZone).toBe("EST");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue