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

LibJS: Implement the Extend TimeZoneName Option Proposal

This is a stage 4 proposal that was recently merged into the main
ECMA-402 spec. See:

1ba5ee7
This commit is contained in:
Timothy Flynn 2022-01-02 14:56:06 -05:00 committed by Linus Groh
parent 126a3fe180
commit 022b416570
5 changed files with 92 additions and 21 deletions

View file

@ -359,11 +359,13 @@ describe("normal behavior", () => {
});
test("all valid timeZoneName options", () => {
["short", "long"].forEach(timeZoneName => {
expect(() => {
new Intl.DateTimeFormat("en", { timeZoneName: timeZoneName });
}).not.toThrow();
});
["short", "long", "shortOffset", "longOffset", "shortGeneric", "longGeneric"].forEach(
timeZoneName => {
expect(() => {
new Intl.DateTimeFormat("en", { timeZoneName: timeZoneName });
}).not.toThrow();
}
);
});
test("all valid formatMatcher options", () => {

View file

@ -377,6 +377,10 @@ describe("timeZoneName", () => {
const data = [
{ timeZoneName: "short", en0: "12/7/2021, 5:40 PM UTC", en1: "1/23/1989, 7:08 AM UTC", ar0: "٧/١٢‏/٢٠٢١, ٥:٤٠ م UTC", ar1: "٢٣‏/١/١٩٨٩, ٧:٠٨ ص UTC" },
{ timeZoneName: "long", en0: "12/7/2021, 5:40 PM Coordinated Universal Time", en1: "1/23/1989, 7:08 AM Coordinated Universal Time", ar0: "٧/١٢‏/٢٠٢١, ٥:٤٠ م التوقيت العالمي المنسق", ar1: "٢٣‏/١/١٩٨٩, ٧:٠٨ ص التوقيت العالمي المنسق" },
{ timeZoneName: "shortOffset", en0: "12/7/2021, 5:40 PM GMT", en1: "1/23/1989, 7:08 AM GMT", ar0: "٧/١٢‏/٢٠٢١, ٥:٤٠ م غرينتش", ar1: "٢٣‏/١/١٩٨٩, ٧:٠٨ ص غرينتش" },
{ timeZoneName: "longOffset", en0: "12/7/2021, 5:40 PM GMT", en1: "1/23/1989, 7:08 AM GMT", ar0: "٧/١٢‏/٢٠٢١, ٥:٤٠ م غرينتش", ar1: "٢٣‏/١/١٩٨٩, ٧:٠٨ ص غرينتش" },
{ timeZoneName: "shortGeneric", en0: "12/7/2021, 5:40 PM GMT", en1: "1/23/1989, 7:08 AM GMT", ar0: "٧/١٢‏/٢٠٢١, ٥:٤٠ م غرينتش", ar1: "٢٣‏/١/١٩٨٩, ٧:٠٨ ص غرينتش" },
{ timeZoneName: "longGeneric", en0: "12/7/2021, 5:40 PM GMT", en1: "1/23/1989, 7:08 AM GMT", ar0: "٧/١٢‏/٢٠٢١, ٥:٤٠ م غرينتش", ar1: "٢٣‏/١/١٩٨٩, ٧:٠٨ ص غرينتش" },
];
test("all", () => {

View file

@ -186,9 +186,11 @@ describe("correct behavior", () => {
});
test("timeZoneName", () => {
["short", "long"].forEach(timeZoneName => {
const en = new Intl.DateTimeFormat("en", { timeZoneName: timeZoneName });
expect(en.resolvedOptions().timeZoneName).toBe(timeZoneName);
});
["short", "long", "shortOffset", "longOffset", "shortGeneric", "longGeneric"].forEach(
timeZoneName => {
const en = new Intl.DateTimeFormat("en", { timeZoneName: timeZoneName });
expect(en.resolvedOptions().timeZoneName).toBe(timeZoneName);
}
);
});
});