CMM-1095: Fix stats off-by-an-hour by reading the site's named timezone - #23124
Merged
adalpari merged 2 commits intoJul 22, 2026
Merged
Conversation
The site-info endpoint returns the Olson timezone under `options.timezone`, not `timezone_string`, so the previous fix silently fell back to the stale numeric `gmt_offset`, shifting the stats "day" boundary by an hour across DST. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Collaborator
Generated by 🚫 Danger |
Contributor
|
|
Contributor
|
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #23124 +/- ##
==========================================
+ Coverage 37.71% 37.74% +0.02%
==========================================
Files 2343 2343
Lines 127380 127380
Branches 17674 17674
==========================================
+ Hits 48047 48078 +31
+ Misses 75393 75358 -35
- Partials 3940 3944 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
adalpari
marked this pull request as ready for review
July 21, 2026 14:44
adalpari
enabled auto-merge (squash)
July 22, 2026 08:01
adalpari
deleted the
cmm-1095-jetpack-app-jetpack-stats-are-off-by-an-hour
branch
July 22, 2026 08:16
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.


Description
Daily stats reset to zero an hour early (e.g. at 23:00 instead of 00:00) for
users whose site uses a DST timezone, such as
Europe/Madrid.The previous fix (#22480) intended to make the stats "day" boundary DST-safe by
storing the site's named (Olson) timezone in
SiteModel.timezoneand lettingSiteUtils.getNormalizedTimezoneresolve DST from it. However, it read the wrongJSON field: the WP.com API exposes the named timezone under different keys
depending on the endpoint:
/me/sites,/sites/$id) →options.timezone(e.g."Europe/Madrid")/sites/$id/settings) →settings.timezone_stringBecause the site-info response never contains
timezone_string, the condition wasalways false and
SiteModel.timezonefell back to the numericgmt_offset. Anumeric offset carries no DST rules and goes stale across DST transitions, so
"today" could be computed an hour ahead — at 23:00 Madrid (22:00 UTC → 00:00 in a
stale GMT+2) the app requested tomorrow's date and the server returned zeros.
This PR reads the correct
options.timezonefield. The DST-safe normalizationadded in #22480 is unchanged and now actually receives a named zone.
Note: this affects the legacy stats screen (
ui/stats/refresh/…), which derivesthe request date from
SiteModel.timezone. The newerui/newstats/…screen usesthe device timezone and is out of scope here.
Testing instructions
Note
This fix only affects the old stats screen. To see the old stats screen you
must log in with a non-admin user (admins are routed to the new stats screen).
the current day, matching the web Jetpack stats.