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

LibJS/Temporal: Allow annotations after YYYY-MM and MM-DD

This is a normative change in the Temporal spec.

See: 160e836
This commit is contained in:
Luke Wilde 2023-02-11 01:05:28 +00:00 committed by Linus Groh
parent 421b1eee49
commit 588dae8aa6
8 changed files with 290 additions and 136 deletions

View file

@ -27,19 +27,9 @@ describe("normal behavior", () => {
["Etc/GMT-12", "Etc/GMT-12"],
["Europe/London", "Europe/London"],
["Europe/Isle_of_Man", "Europe/London"],
["1970-01-01+01", "+01:00"],
["1970-01-01+01[-12:34]", "-12:34"],
["1970-01-01T00:00:00+01", "+01:00"],
["1970-01-01T00:00:00.000000000+01", "+01:00"],
["1970-01-01T00:00:00.000000000+01:00:00", "+01:00"],
["1970-01-01+12:34", "+12:34"],
["1970-01-01+12:34:56", "+12:34:56"],
["1970-01-01+12:34:56.789", "+12:34:56.789"],
["1970-01-01+12:34:56.789[-01:00]", "-01:00"],
["1970-01-01-12:34", "-12:34"],
["1970-01-01-12:34:56", "-12:34:56"],
["1970-01-01-12:34:56.789", "-12:34:56.789"],
["1970-01-01-12:34:56.789[+01:00]", "+01:00"],
];
for (const [arg, expected] of values) {
expect(Temporal.TimeZone.from(arg).id).toBe(expected);
@ -75,4 +65,25 @@ describe("errors", () => {
"Got unexpected Calendar object in conversion to TimeZone"
);
});
test("invalid time zone strings", () => {
const values = [
"1970-01-01+01",
"1970-01-01+01[-12:34]",
"1970-01-01+12:34",
"1970-01-01+12:34:56",
"1970-01-01+12:34:56.789",
"1970-01-01+12:34:56.789[-01:00]",
"1970-01-01-12:34",
"1970-01-01-12:34:56",
"1970-01-01-12:34:56.789",
"1970-01-01-12:34:56.789[+01:00]",
];
for (const value of values) {
expect(() => {
Temporal.TimeZone.from(value);
}).toThrowWithMessage(RangeError, "Invalid ISO date time");
}
});
});