[wp-trac] [WordPress Trac] #60105: Add a timezone offset display value to `wp.date.setSettings`

WordPress Trac noreply at wordpress.org
Tue Dec 19 12:47:30 UTC 2023


#60105: Add a timezone offset display value to `wp.date.setSettings`
---------------------------+-------------------------
 Reporter:  afercia        |      Owner:  (none)
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  6.5
Component:  Script Loader  |    Version:
 Severity:  normal         |   Keywords:  needs-patch
  Focuses:                 |
---------------------------+-------------------------
 In https://github.com/WordPress/gutenberg/pull/56682 I'm proposing to add
 a timezone offset value for displaying purposes, to be used in the
 Gutenberg editor.

 Right now, the editor is displaying the stored value which is a float
 number with decimals. For some timezone offsets, that displays incorrect
 values in the UI like `5:75` instead of `5:45`.

 There's already a couple places in Core where such a conversion is in
 place for displaying purposes:
 - In [https://github.com/WordPress/wordpress-
 develop/blob/7c492d36e0c6e219e54ce22eb6d1f5ae4610092b/src/wp-
 includes/functions.php#L6701 the select element] for the Timezone setting.
 - In the customizer [https://github.com/WordPress/wordpress-
 develop/blob/7c492d36e0c6e219e54ce22eb6d1f5ae4610092b/src/wp-
 includes/customize/class-wp-customize-date-time-control.php#L306-L318
 WP_Customize_Date_Time_Control class].


 It would be a one line addition:

 {{{
 'offsetFormatted' => str_replace( array( '.25', '.5', '.75' ), array(
 ':15', ':30', ':45' ), (string) get_option( 'gmt_offset', 0 ),
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60105>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list