Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. 🫖 Status page with uptime monitoring & API monitoring as code 🫖 openstatus.dev
bun drizzle-orm monitoring monitoring-as-code nextjs observability on-call open-source shadcn-ui status-page statuspage synthetic-monitoring tinybird turso uptime uptime-checker uptime-monitor
Something went wrong. Try again.
2.1 kB · 64 lines
TypeScript
at main
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465import { describe, expect, it } from "vitest";
import { resolveTimeZone, timeZoneShortName, timeZoneShortNames,} from "./timezone";
describe("resolveTimeZone", () => { it("keeps a zone the runtime knows", () => { expect(resolveTimeZone("Asia/Tokyo")).toBe("Asia/Tokyo"); });
it("collapses UTC aliases", () => { expect(resolveTimeZone("Etc/UTC")).toBe("UTC"); expect(resolveTimeZone("GMT")).toBe("UTC"); });
it("keeps a zone Intl would rename", () => { expect(resolveTimeZone("Asia/Kolkata")).toBe("Asia/Kolkata"); });
it("falls back to UTC for an unknown zone", () => { expect(resolveTimeZone("Mars/Olympus")).toBe("UTC"); });});
describe("timeZoneShortName", () => { it("keeps UTC as is", () => { expect(timeZoneShortName("UTC")).toBe("UTC"); });
it("renders the locale's short name", () => { expect(timeZoneShortName("Asia/Tokyo")).toBe("GMT+9"); expect(timeZoneShortName("Asia/Tokyo", "ja")).toBe("JST"); });
it("names the zone as of the given instant", () => { const winter = new Date("2026-01-15T12:00:00Z"); const summer = new Date("2026-07-15T12:00:00Z"); expect(timeZoneShortName("America/New_York", "en-US", winter)).toBe("EST"); expect(timeZoneShortName("America/New_York", "en-US", summer)).toBe("EDT"); expect(timeZoneShortName("Europe/Berlin", "en-US", winter)).toBe("GMT+1"); expect(timeZoneShortName("Europe/Berlin", "en-US", summer)).toBe("GMT+2"); });});
describe("timeZoneShortNames", () => { it("names a span once when it stays in one offset", () => { const from = new Date("2026-01-15T12:00:00Z"); const to = new Date("2026-01-15T14:00:00Z"); expect(timeZoneShortNames("America/New_York", "en-US", [from, to])).toBe( "EST", ); });
it("names both ends of a span that crosses a DST change", () => { const from = new Date("2026-03-08T06:00:00Z"); const to = new Date("2026-03-08T08:00:00Z"); expect(timeZoneShortNames("America/New_York", "en-US", [from, to])).toBe( "EST/EDT", ); });});