-
Notifications
You must be signed in to change notification settings - Fork 4.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
Date: Ensure timezone offset is a number #25684
Conversation
When using a UTC offset timezone (instead of a named timezone), the offset is saved as a numeric string. This is not understood by moment, which expects either a number or a formatted string (ex "+08:00").
Size Change: +4 B (0%) Total Size: 1.17 MB
ℹ️ View Unchanged
|
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.
I realize this is a bit stale, but LGTM!
I've got to note though that __experimentalGetOffset
does not exist—#21977 (comment) is probably referencing __experimentalGetSettings
. This change still affects formatting when using other functions within @wordpress/date
.
Thanks for this! I'm not sure where I got |
Pinging @noisysocks in the context of #21977 (comment) |
I have checked the latest trunk status. gutenberg/packages/date/src/index.js Line 614 in 1b5994a
@noisysocks |
Yes #39670 included essentially what's in this PR. |
When using a UTC offset timezone (instead of a named timezone), the offset is saved as a numeric string. This is not understood by moment, which expects either a number or a formatted string (ex "+08:00"). This means dates are not formatted correctly for sites with
UTC
timezones. You can see this by changing the settings on a site between 2 options that represent the same time, ex "UTC-7" and "Vancouver".Alternately you can see the problem more clearly by trying to pass in a string timezone offset to
date
:Fixes #21977
How has this been tested?
Tested in browser as described above (with UTC-7 and UTC+1:30), and ran unit tests.
Types of changes
Bug fix (non-breaking change which fixes an issue)