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

LibJS: Support non-UTC time zones in Temporal :^)

We can now recognize & normalize all time zones from the IANA time zone
database and not just 'UTC', which makes the LibJS Temporal
implementation a lot more useful! Thanks to the newly added LibTimeZone,
this was incredibly easy to implement :^)

This already includes these recent editorial changes in the Temporal
spec: 27bffe1
This commit is contained in:
Linus Groh 2022-01-11 20:20:16 +01:00
parent 205d63c3f0
commit d527eb62da
5 changed files with 49 additions and 27 deletions

View file

@ -36,9 +36,22 @@ describe("normal behavior", () => {
});
test("canonicalizes time zone name", () => {
expect(new Temporal.TimeZone("Utc").id).toBe("UTC");
expect(new Temporal.TimeZone("utc").id).toBe("UTC");
expect(new Temporal.TimeZone("uTC").id).toBe("UTC");
const values = [
["UTC", "UTC"],
["Utc", "UTC"],
["utc", "UTC"],
["uTc", "UTC"],
["GMT", "UTC"],
["Etc/UTC", "UTC"],
["Etc/GMT", "UTC"],
["Etc/GMT+12", "Etc/GMT+12"],
["Etc/GMT-12", "Etc/GMT-12"],
["Europe/London", "Europe/London"],
["Europe/Isle_of_Man", "Europe/London"],
];
for (const [arg, expected] of values) {
expect(new Temporal.TimeZone(arg).id).toBe(expected);
}
});
test("numeric UTC offset", () => {