fix(rollup): compute ISO week from UTC calendar fields#411
Open
nankingjing wants to merge 1 commit into
Open
Conversation
Author
|
Reviewed — using UTC getters avoids date shift when the process runs outside CST, a clean timezone fix. Ready for review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
toWeekStr()insrc/rollup.tsbuilds the ISO-week label shown in the weekly report title and GitHub issue title (e.g.AI 工具生态周报 2026-W22). It reads the calendar date with local-timezone getters:Callers pass a CST timestamp (
cstDate = now + 8h) whose UTC fields hold the intended CST date — every other date computation in the file and insrc/index.tsreads it viatoISOString()/getUTC*(). MixinggetFullYear()/getMonth()/getDate()here means the day (and therefore the ISO week/year) shifts whenever the process runs outside UTC.The weekly workflow even computes the same week independently as
date -u +%Y-W%V(UTC) for the commit message, so under a non-UTC timezone the report title and the commit message would disagree.Fix
Read the calendar date with UTC getters, consistent with the rest of the codebase:
This is a no-op when the process runs in UTC (current CI), and produces the correct, stable ISO week everywhere else.
Verification
Reproduction with the exact function flow (
cstDate = now + 8h):now(UTC)2026-W01❌2026-W02✅2026-W21❌2026-W22✅2026-W52❌2026-W53✅(run under
TZ=PST8PDT; underTZ=UTCboth columns match, confirming no regression). The "after" column matches an independent ISO-week reference.Ran against the repo with the change applied:
pnpm typecheck,pnpm lint, andpnpm format:checkall pass.