From 9d287637533e85c7e536a6b3b57d96fa8240dd85 Mon Sep 17 00:00:00 2001 From: Conroy Whitney Date: Wed, 28 Jan 2026 21:46:29 -0500 Subject: [PATCH] test: add DST boundary test for timestamp injection Verifies that America/New_York correctly resolves to midnight for both EST (winter, UTC-5) and EDT (summer, UTC-4) using the same IANA timezone. Intl.DateTimeFormat handles the DST transition. --- .../server-methods/agent-timestamp.test.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/gateway/server-methods/agent-timestamp.test.ts b/src/gateway/server-methods/agent-timestamp.test.ts index bce2d9435..eb24e02eb 100644 --- a/src/gateway/server-methods/agent-timestamp.test.ts +++ b/src/gateway/server-methods/agent-timestamp.test.ts @@ -97,6 +97,26 @@ describe("injectTimestamp", () => { expect(result).toContain("11:59 PM"); }); + it("handles DST correctly (same UTC hour, different local time)", () => { + // EST (winter): UTC-5 → 2026-01-15T05:00Z = midnight Jan 15 + vi.setSystemTime(new Date("2026-01-15T05:00:00.000Z")); + const winter = injectTimestamp("winter", { + timezone: "America/New_York", + timeFormat: "12", + }); + expect(winter).toContain("January 15"); + expect(winter).toContain("12:00 AM"); + + // EDT (summer): UTC-4 → 2026-07-15T04:00Z = midnight Jul 15 + vi.setSystemTime(new Date("2026-07-15T04:00:00.000Z")); + const summer = injectTimestamp("summer", { + timezone: "America/New_York", + timeFormat: "12", + }); + expect(summer).toContain("July 15"); + expect(summer).toContain("12:00 AM"); + }); + it("accepts a custom now date", () => { const customDate = new Date("2025-07-04T16:00:00.000Z"); // July 4, noon EST