|
9 | 9 | localizeDuration, |
10 | 10 | localizeRelativeTime, |
11 | 11 | localizeTimeOffset, |
| 12 | + localizeTimeZone, |
12 | 13 | } from "utils/date"; |
13 | 14 |
|
14 | 15 | const janFirst2000 = Temporal.PlainDateTime.from("2000-01-01"); |
@@ -460,6 +461,42 @@ describe("localizeDuration", () => { |
460 | 461 | }); |
461 | 462 | }); |
462 | 463 |
|
| 464 | +describe("localizeTimeZone", () => { |
| 465 | + // Use timezones that have no daylight time or the test will produce different results |
| 466 | + // depending on the time of the year. |
| 467 | + it("supports for different time zones", () => { |
| 468 | + expect(localizeTimeZone("Asia/Shanghai", "en")).toBe("China Standard Time"); |
| 469 | + expect(localizeTimeZone("America/Mexico_City", "en")).toBe( |
| 470 | + "Central Standard Time", |
| 471 | + ); |
| 472 | + }); |
| 473 | + |
| 474 | + it("supports for different languages", () => { |
| 475 | + expect(localizeTimeZone("Asia/Shanghai", "en")).toBe("China Standard Time"); |
| 476 | + expect(localizeTimeZone("Asia/Shanghai", "es")).toBe( |
| 477 | + "hora estándar de China", |
| 478 | + ); |
| 479 | + }); |
| 480 | + |
| 481 | + it("supports short and long forms", () => { |
| 482 | + expect(localizeTimeZone("Atlantic/Reykjavik", "en", { short: false })).toBe( |
| 483 | + "Greenwich Mean Time", |
| 484 | + ); |
| 485 | + expect(localizeTimeZone("Atlantic/Reykjavik", "en", { short: true })).toBe( |
| 486 | + "GMT", |
| 487 | + ); |
| 488 | + }); |
| 489 | + |
| 490 | + it("supports for capitalization", () => { |
| 491 | + expect(localizeTimeZone("Asia/Shanghai", "es", { capitalize: false })).toBe( |
| 492 | + "hora estándar de China", |
| 493 | + ); |
| 494 | + expect(localizeTimeZone("Asia/Shanghai", "es", { capitalize: true })).toBe( |
| 495 | + "Hora estándar de China", |
| 496 | + ); |
| 497 | + }); |
| 498 | +}); |
| 499 | + |
463 | 500 | describe("approxTimeDuration", () => { |
464 | 501 | it("converts years, months, weeks and days to hours", () => { |
465 | 502 | expect( |
|
0 commit comments