Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#56459 closed defect (bug) (fixed)

Editor: wp.date.setSettings() passes timezone.offset a string instead of a float

Reported by: noisysocks's profile noisysocks Owned by: noisysocks's profile noisysocks
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

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

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

#3 @noisysocks
3 years ago

  • Keywords commit added

Thanks @talldanwp!

#4 @noisysocks
3 years ago

  • Owner set to noisysocks
  • Resolution set to fixed
  • Status changed from new to closed

In 53956:

Editor: Ensure that timezone.offset passed to @wordpress/date is a float

Fixes inconsistent type of timezone.offset passed to @wordpress/date. It
should always be a float, never a string.

Props talldanwp.
Fixes #56459.

noisysocks commented on PR #3151:


3 years ago
#5

Committed in r53956.

#6 @desrosj
3 years ago

  • Milestone changed from Future Release to 6.1
Note: See TracTickets for help on using tickets.