periodOf keyed a week by the Monday's YYYY-MM-DD, which collides with the day-key form. Weeks now key as YYYY-Www (ISO 8601, e.g. 2025-W32); the week-year comes from the week's Thursday, so it stays correct across the January/December boundary. The Monday-start boundary and startsAt are unchanged. Week tests now assert the ISO form. Model: opus-4-8
This commit is contained in:
@@ -287,8 +287,9 @@ describe("lib.timeline grouping", () => {
|
||||
],
|
||||
);
|
||||
const groups = apis(records).timeline.groups({ groupBy: "week" });
|
||||
expect(groups.map((g) => g.key)).toEqual(["2024-01-22", "2024-01-15"]);
|
||||
const first = groups.find((g) => g.key === "2024-01-15")!;
|
||||
// ISO week keys: 2024-01-15 is in 2024-W03, the next Monday in 2024-W04.
|
||||
expect(groups.map((g) => g.key)).toEqual(["2024-W04", "2024-W03"]);
|
||||
const first = groups.find((g) => g.key === "2024-W03")!;
|
||||
expect(first.startsAt).toBe(Date.UTC(2024, 0, 15));
|
||||
// The Sunday belongs to the Monday-started week, not the next one.
|
||||
expect(first.fileIDs.sort((a, b) => a - b)).toEqual([1, 2, 3]);
|
||||
@@ -301,7 +302,7 @@ describe("lib.timeline grouping", () => {
|
||||
[file(1, 1, { creationTime: micros(Date.UTC(2024, 0, 14, 12)) })],
|
||||
);
|
||||
const groups = apis(records).timeline.groups({ groupBy: "week" });
|
||||
expect(groups.map((g) => g.key)).toEqual(["2024-01-08"]);
|
||||
expect(groups.map((g) => g.key)).toEqual(["2024-W02"]);
|
||||
expect(groups[0]!.startsAt).toBe(Date.UTC(2024, 0, 8));
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user