Option to conditionally drop minutes (when :00) and am/pm from time

Created on 6 April 2018, over 6 years ago
Updated 23 August 2024, 4 months ago

I have my formats setup like this:

January 1st 2017
January 2 – 3rd 2017
January 4 – 5th 2017
January 6th 2017 – January 7th 2018
January 1st 2017, 9:00am
January 1st 2017, 9:00am – 1:00pm
January 1st 2017, 9:00am – January 2nd 2017, 1:00pm

Many of these strings could be compacted quite a bit more, in two ways:

1) Remove :00 from hour

The hours settings are g:ia.

On "basic" date & time format, have an option to strip the :i from the format when i = 00, to end up with strings like this:

January 1st 2017, 9am
January 1st 2017, 9am – 10:30am
January 1st 2017, 9am – January 2nd 2017, 1pm

2) Remove duplicate am/pm when start and end time are in the same meridian.

On "same day" setting, have an option to strip the first a or A from the format when the meridian on both times are the same, to end up with strings like this:

9–10:30am, January 1st 2017

Feature request
Status

Fixed

Version

1.0

Component

Code

Created by

🇪🇨Ecuador jwilson3

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇸🇪Sweden erik.erskine

    Both of these features are now part of 2.1.0.

  • Automatically closed - issue fixed for 2 weeks with no activity.

  • 🇪🇨Ecuador jwilson3

    Just wanted to come back around and say that this feature is fantastic. Thanks for implementing it. 👏 🎉

    Is there a chance we could add more examples that display the variants when same_day_omit_duplicate_ampm and/or zero_minutes_omit are set to TRUE, on the main listing page at /admin/config/regional/daterange-compact-format ?

  • 🇸🇪Sweden erik.erskine

    Thank you @jwilson3!

    Is there a chance we could add more examples that display the variants when same_day_omit_duplicate_ampm and/or zero_minutes_omit are set to TRUE, on the main listing page at /admin/config/regional/daterange-compact-format ?

    Good idea. I've tweaked the existing examples a bit, so that those features are triggered:

    • Jan 1, 2017 9am
    • Jan 1, 2017 9-10:30am
    • Jan 6, 2017 9am - Jan 7, 2018 10am
Production build 0.71.5 2024