web: fix ✨ timezone issues ✨ so midnight ISR happens the right day
This commit is contained in:
@@ -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;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user