Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/rollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ function readWeeklyDigest(date: string): string | null {

/** Format a date as ISO week string, e.g. "2026-W10". */
function toWeekStr(date: Date): string {
// ISO week: week containing the first Thursday of the year
const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
// ISO week: week containing the first Thursday of the year.
// Read the calendar date via UTC getters: callers pass a CST timestamp whose
// UTC fields hold the intended CST date, so local getters would shift the day
// (and thus the week/year) whenever the process runs outside UTC.
const d = new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()));
d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
const week = Math.ceil(((d.getTime() - yearStart.getTime()) / 86400000 + 1) / 7);
Expand Down