fix(dashboard): make activity date keys/range independent of server TZ#73
Open
Chzhqv wants to merge 1 commit into
Open
fix(dashboard): make activity date keys/range independent of server TZ#73Chzhqv wants to merge 1 commit into
Chzhqv wants to merge 1 commit into
Conversation
Date-only fields are stored as UTC midnight of the intended calendar day (e.g. "2026-01-15" parses to 2026-01-15T00:00:00.000Z). The activity route read these back with date-fns' format()/startOfMonth()/ endOfMonth(), which use the server process's local timezone — on a server not running in UTC, this could both shift an entry onto the adjacent calendar day and query the wrong month's range entirely. Extracted toDateKey/utcMonthRange into src/lib/date-key.ts (UTC-getter based, so the result no longer depends on server TZ) and use them in the activity route. Verified live: reproduced on this machine's own EST dev server (a real negative-UTC-offset environment) — an expense dated "2026-01-15" was previously invisible in the January activity map entirely (wrong month range) and would have kept appearing under "2026-01-14" once the range was fixed (day-key mismatch); with both fixes it correctly appears under "2026-01-15". Added regression tests that flip process.env.TZ across the fetch and assert the correct UTC-anchored result (confirmed they fail against the old date-fns-based implementation and pass against the fix). Fixes TemaDeveloper#23
|
Someone is attempting to deploy a commit to the Artemii's projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
Summary
"2026-01-15"parses to2026-01-15T00:00:00.000Z). The dashboard activity route read these back with date-fns'format()/startOfMonth()/endOfMonth(), which use the server process's local timezone — on a server not running in UTC, this could both shift an entry onto the adjacent calendar day and query the wrong month's range entirely.toDateKey/utcMonthRangeintosrc/lib/date-key.ts(UTC-getter based, independent of server TZ) and use them in the activity route.Test plan
"2026-01-15"was invisible in the January activity map entirely before the range fix (querying essentially December's UTC range instead), and would have appeared under the wrong key"2026-01-14"once only the range was fixed; with both fixes it correctly appears under"2026-01-15"lib/__tests__/date-key.test.ts) that flipprocess.env.TZacross the assertion (EST, UTC+14, UTC) and confirm the UTC-anchored result stays correct — confirmed they fail against the old date-fns-based implementation and pass against the fixpnpm lint,tsc --noEmit, fullvitest run(558/558) all passFixes #23