[wp-trac] [WordPress Trac] #56459: Editor: wp.date.setSettings() passes timezone.offset a string instead of a float
WordPress Trac
noreply at wordpress.org
Tue Aug 30 00:07:39 UTC 2022
#56459: Editor: wp.date.setSettings() passes timezone.offset a string instead of a
float
--------------------------+----------------------------
Reporter: noisysocks | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Future Release
Component: Editor | Version: trunk
Severity: normal | Keywords: has-patch
Focuses: javascript |
--------------------------+----------------------------
From https://github.com/WordPress/gutenberg/issues/21977.
The value provided by wp.date.__getExperimentalSettings.timezone.offset
differs in type depending on the site's timezone setting.
A timezone of America/Los_Angeles set through General Settings in the
WordPress admin results in an integer offset value of -7 (currently in
DST).
- A timezone of UTC-7 results in a string offset value of "-7".
- A timezone of UTC results in an integer offset value of 0.
- A timezone of UTC+0 results in a string offset value of "0".
- If this data is passed directly to something like moment().utcOffset(),
which expects either an integer or a string formatted like "-07:00", then
the returned object will not contain the expected offset information.
Any of these values can be passed through Number() or converted to minutes
via * 60, which moment also understands, so I could see how this isn't
necessarily a bug bug, but having this documented here may help someone
else who started questioning the world a bit. :)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56459>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list