Skip to content

Timezone displays offset with decimals instead of minutes #56254

Closed

Description

@afercia

Description

Splitting this out from #56211 (comment)

When the WordPress timezone setting is set to a time zone with minutes e.g. UTC+5:45, the actual value stored internally is a number with decimals e.g. 5.75.

There's a couple places in the editor where this value is displayed 'as is' with decimals, which is incorrect; For example, the timezone component and the post-schedule label:

Screenshot 2023-11-17 at 14 57 49

Instead of 5.75 it should be 5:45.

WordPress core handles this case in a couple places with a simple string manipulation, so to have an appropriate value to be displayed. See the select for the timezone setting and in the customizer.

Instead, Gutenberg displays the value 'as is'.

Proposed solution

At first, I tried to fix this 'locally' in the components but then I realized it would be best to fix it in the Date settings. Adding a 'display value' there would be best, so that it is available everywhere and can be used where necessary.

The relevant data are set via wp.date.setSettings() in the script loader here and then retrieved via wp.date.getSettings().

This would require a change in WP core and a compat file.

Step-by-step reproduction instructions

  • Go to the WordPress admin Settings > General Settings > Timezone.
  • Set the Timezone value to UTC+5:45 and save.
  • Go to the post editor and publish a new post.
  • Click the Publish date in the settings panel.
  • Observe that both the Publish date and the timezone indication in the Publish popover display UTC+5.75.
  • Expected: UTC+5:45

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

Activity

  1. added
    [Type] Bug
    [Package] Date
    [Package] Components
    [Package] Editor
    on Nov 17, 2023
  2. self-assigned this
    on Nov 17, 2023
  3. afercia commented on Nov 17, 2023

    @afercia
    ContributorAuthor

    Besides the cases where timezone.offset is used for display purposes, there may be other cases where the value is used internally. I'd appreciate some help with double checking all the potential cases that may be impacted.

  4. added
    [Status] In Progress
    on Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

[Package] Components[Package] Date[Package] Editor[Status] In Progress[Type] Bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions