-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stats: datetime localization improvements #97724
Conversation
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: Sections (~71 bytes added 📈 [gzipped])
Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to. Async-loaded Components (~65 bytes added 📈 [gzipped])
React components that are loaded lazily, when a certain part of UI is displayed for the first time. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice refactoring! LGTM 👍
Thanks for taking the time to review, @kangzj. I'll merge/deploy it sometime after Christmas. |
Related to #76912.
Proposed Changes
getMomentSiteZone()
implementation;Moment
instance;UTC
, if the site timezone isn't available.The suggestion was to use
withLocalizedMoment()
, but that wouldn't work in thegetMomentSiteZone()
function. It returns aMoment
instance and not an actual React component to be wrapped by a High-Order Component (HOC).It was also suggested to use the current user timezone as an intermediate fallback, but this information doesn't actually exist (p1734669805865359-slack-C82FZ5T4G). We only have site and browser timezone information.
Why are these changes being made?
This PR implements the suggestions made on issue #76912, improving how datetime localization is handled.
Testing Instructions
I'm not aware of an example site that lacks the
gmt_offset
option, so the easiest way to simulate the fallback is to comment the linereturn localizedMoment.utcOffset( gmtOffset );
. After that, it's possible to explore datetime information in the chart available at/stats/day/jetpack.com
.Pre-merge Checklist