fix(due,store,ui): month grid steps by calendar day so dst cannot repeat one

This commit is contained in:
hh committed 2026-10-18 20:18:03 +02:00
1 parent e7178c6d3f
commit 3424222dab
4 files changed
+50 -24

No files matched your search

+30 -1
View File
@@ -1,8 +1,10 @@
import { describe, expect, it } from "vitest";
import { afterAll, beforeAll, describe, expect, it } from "vitest";
import {
daysFromToday,
dueLabel,
dueTone,
localKey,
monthGrid,
nextFriday,
} from "../src/lib/due";
@@ -26,3 +28,30 @@ describe("due helpers read the day they are given", () => {
expect(nextFriday("2026-08-28")).toBe("2026-09-04");
});
});
describe("monthGrid steps by calendar day", () => {
const zone = process.env.TZ;
beforeAll(() => {
process.env.TZ = "Europe/Berlin";
});
afterAll(() => {
process.env.TZ = zone;
});
it("keeps every day once across the autumn clock change", () => {
const keys = monthGrid(new Date(2026, 9, 1)).map(localKey);
expect(keys).toHaveLength(42);
expect(new Set(keys).size).toBe(42);
expect(keys[0]).toBe("2026-09-28");
expect(keys[27]).toBe("2026-10-25");
expect(keys[28]).toBe("2026-10-26");
expect(keys[41]).toBe("2026-11-08");
});
it("keeps every day once across the spring clock change", () => {
const keys = monthGrid(new Date(2027, 2, 1)).map(localKey);
expect(new Set(keys).size).toBe(42);
expect(keys).toContain("2027-03-28");
expect(keys).toContain("2027-03-29");
});
});