Time format: add hours Suffix

Created on 21 December 2023, about 1 year ago
Updated 28 February 2024, 10 months ago

Problem/Motivation

In some countries it is advisable to display the time with a suffix. For example in Belgium we do "9:00u". I was looking into the code, but saw the time notation is going to change as there is a comment "@todo D8 Align with DateTimeDatelistWidget."
So I'm not sure if we would be willing to change the code for the suffix now or first refactor to the align with DateTimeDatelistWidget and is it even possible then to have the suffix? Or that could be a core feature request then?

So for example grouped time notation is 9:00-17:00 and could be changed to 9:00u-17:00u.

Steps to reproduce

-

Proposed resolution

Allow to choose a suffix in the formatters for the time notation.

Remaining tasks

Discuss if this is something that can be added and if that can be done before the refactor or after.

User interface changes

Adding a suffix field to the formatters.

API changes

-

Data model changes

There will be a suffix field that needs storage.

Feature request
Status

Closed: works as designed

Version

1.16

Component

Code - formatter

Created by

🇧🇪Belgium tim-diels Belgium 🇧🇪

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @tim-diels
  • 🇳🇱Netherlands johnv

    in the past, I had several requests for reformatting the time.
    e.g., in php, ony am/pm is supported, whereas AM/PM or a.m./p.m. was desired.

    That is why I added a hook, so each could user there own requirements. Please check the office_hours.api.php file.

  • 🇧🇪Belgium tim-diels Belgium 🇧🇪

    I understand that it would be almost impossible to maintain all request around this.
    But instead of hardcoding the 4 formatters that are there now, we could introduce a plugin system for the time formatting.
    In that way, someone would be able to provide more time formatters if needed and is more straightforward then working with hooks.
    Also I'm fan of making the site building experience more easy and having to code this every time over and over would be not productive.
    Would you be open to the plugin system? Then I could start with the once that are already provided and then I can easily maintain the others myself or add them if wanted.

  • 🇳🇱Netherlands johnv

    We can leverage the admin/config/regional/date-time functionality.
    I am willing to support that. It will require an update hook, too.

    But that does not solve the am/pm vs AM/PM vs. A.M./P.M. issue, for instance.
    So it would not replace the hook. Or do you think otherwise?

  • 🇳🇱Netherlands johnv

    Renaming the issue,
    now it resembles more all other issues from time formatting: Time format issues for Formatter

  • 🇳🇱Netherlands johnv

    You might want to check Formatter: Add Event to allow other modules to modify values Fixed . It redirects to the new alter_hook and events.

  • Status changed to Closed: works as designed 10 months ago
  • 🇳🇱Netherlands johnv

    I guess this can also be done with some small code via Formatter: Add Event to allow other modules to modify values Fixed .
    Feel free to re-open if you have alternative solutions.

Production build 0.71.5 2024