web: fix timezone issues so midnight ISR happens the right day

This commit is contained in:
2026-09-04 21:28:17 +02:00
parent b7ff7a3ddc
commit a678adc9d3
7 changed files with 72 additions and 13 deletions
+19
View File
@@ -161,4 +161,23 @@ describe("getTodaysOpeningHoursForFunction", () => {
vi.setSystemTime(new Date("2026-07-07T10:00:00Z"));
expect(getTodaysOpeningHoursForFunction(openingHours, "kafé")).toBe("?");
});
it("uses the Oslo weekday when the server runs in UTC", () => {
const tz = process.env.TZ;
process.env.TZ = "UTC";
try {
// 22:20 UTC on torsdag is 00:20 fredag in Oslo (CEST)
vi.setSystemTime(new Date("2026-07-09T22:20:00Z"));
expect(getTodaysOpeningHoursForFunction(openingHours, "bar")).toBe(
"15:00—01:00"
);
// 23:20 UTC on torsdag is 00:20 fredag in Oslo (CET)
vi.setSystemTime(new Date("2026-01-08T23:20:00Z"));
expect(getTodaysOpeningHoursForFunction(openingHours, "bar")).toBe(
"15:00—01:00"
);
} finally {
process.env.TZ = tz;
}
});
});