Fix PostDate using browser timezone instead of WordPress site timezone#404
Open
s3rgiosan wants to merge 2 commits into10up:developfrom
Open
Fix PostDate using browser timezone instead of WordPress site timezone#404s3rgiosan wants to merge 2 commits into10up:developfrom
s3rgiosan wants to merge 2 commits into10up:developfrom
Conversation
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 of the Change
PostDatewas hardcoding the browser's timezone viaIntl.DateTimeFormat().resolvedOptions().timeZoneand passing it todateI18n(). This overrode the WordPress site's configured timezone, causing the editor to display incorrect timezoneabbreviations (e.g., WET instead of EST).
This PR removes the hardcoded browser timezone and adds an optional
timezoneprop toPostDate. When the prop is notprovided,
dateI18n()correctly falls back to the WordPress site timezone fromgetSettings(), which is the expectedbehavior. The prop can still be used to explicitly override the timezone when needed.
Closes #
How to test the Change
America/New_York(Settings → General) → the editor should show EST/EDT.timezone="Europe/London"prop toPostDate→ should override to GMT/BST.timezoneprop unset with a UTC site setting → should show UTC.Changelog Entry
Credits
Props @s3rgiosan
Checklist:
Conduct.
Tests to cover my change.