Repository navigation
Start day presets at the site's midnight, not the browser's - #9
Merged
Merged
Conversation
"Today", "Last 7 days" and "Last 30 days" took their start from setHours(0, 0, 0, 0) in the browser's zone, while the server buckets in the site's zone. With the two zones apart the window began hours off, e.g. a UTC site viewed from Asia/Kolkata showed six hours of yesterday under "Today". The dashboard now keeps the selected site's time zone in its state and presetRange() uses startOfDay() from @pulse/core with it, falling back to the browser zone until the site list has loaded. Fixes #8
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.
The day presets ("Today", "Last 7 days", "Last 30 days") started at the browser's local midnight (
startOfLocalDay()inweb/src/lib/ranges.ts), but the server snaps ranges onto buckets in the site's time zone. When the two zones differ the window starts hours off: a UTC site viewed from Asia/Kolkata got six hours of the previous day under "Today".Fix: the dashboard store now keeps the selected site's
timeZone(set inAppwhen the site list loads or the site changes).presetRange()takes it and computes the day start withstartOfDay()from@pulse/core, the same function the server's day buckets use. Until the site list has loaded it falls back to the browser zone as before.AnalyticsPageadds the zone to its query key so the data refetches once the zone is known.Testing: new case in
web/test/lib.test.tsfor UTC, Asia/Kolkata and America/New_York; it failed before the change (todayfor Asia/Kolkata returned the browser's midnight, 2026-06-10T00:00Z instead of 2026-06-09T18:30Z). Lint, format check, typecheck, the full test suite (also withTZ=Asia/Kolkata) and the build all pass locally.Fixes #8