#56459 closed defect (bug) (fixed)
Editor: wp.date.setSettings() passes timezone.offset a string instead of a float
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 6.1 | Priority: | normal |
Severity: | normal | Version: | 6.1 |
Component: | Editor | Keywords: | has-patch commit |
Focuses: | javascript | Cc: |
Description
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. :)
Change History (6)
This ticket was mentioned in PR #3151 on WordPress/wordpress-develop by noisysocks.
3 years ago
#1
This ticket was mentioned in PR #3151 on WordPress/wordpress-develop by noisysocks.
3 years ago
#2
Fixes bug described in https://core.trac.wordpress.org/ticket/56459 and https://github.com/WordPress/gutenberg/issues/21977 by casting timezone.offset
to a float before giving it to wp.date.setSettings()
.
Trac ticket: https://core.trac.wordpress.org/ticket/56459
#4
@
3 years ago
- Owner set to noisysocks
- Resolution set to fixed
- Status changed from new to closed
In 53956:
noisysocks commented on PR #3151:
3 years ago
#5
Committed in r53956.
Fixes bug described in https://core.trac.wordpress.org/ticket/56459 and https://github.com/WordPress/gutenberg/issues/21977 by casting
timezone.offset
to a float before giving it towp.date.setSettings()
.Trac ticket: https://core.trac.wordpress.org/ticket/56459