Add support for optional end dates

Created on 5 May 2018, over 6 years ago
Updated 6 September 2024, 4 months ago

The formatter does not support the end date in the date range being optional.

There is a module that makes the end date optional: https://www.drupal.org/project/optional_end_date β†’
And an issue to port this behaviour to core: https://www.drupal.org/project/drupal/issues/2794481 ✨ Allow end date to be optional Needs review

If a field value without an end date is considered to a range consisting of one single date, we should just print that start date.

✨ Feature request
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡³πŸ‡΄Norway matsbla

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

Merge Requests

Comments & Activities

Not all content is available!

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

  • πŸ‡ΊπŸ‡ΈUnited States karlshea Minneapolis πŸ‡ΊπŸ‡Έ

    #10 Works for me using optional_end_date module.

  • πŸ‡ΊπŸ‡ΈUnited States karlshea Minneapolis πŸ‡ΊπŸ‡Έ

    Actually it wasn't working everywhere, updated patch attached.

  • πŸ‡³πŸ‡ΏNew Zealand ericgsmith

    Needs a reroll for 2.1.x but wanted to query something first.

    #10 still applies cleanly but does not work for date fields, only datetime fields. It does this by not modifying the service and passing in the start date for the end date.

    #12 would need a reroll, but it aims to resolve this in DateRangeCompactFormatter by allowing null values rather than changing the default values. But even with formatTimestampRange modified to accept a null value, its keeping the login from #10 to set the end date as the start date.

    I think given this is postponed, it would be simpler to keep the logic for #10 and apply it in the if block for date only fields?

  • πŸ‡ΈπŸ‡ͺSweden erik.erskine

    The approach in #10 is probably the right way: let the field formatter deal with the NULL end date and leave the low level formatter service alone.

    I'd prefer this because there some debate on what a null end value actually means. It could mean a single value, but it could also mean an unbounded range (from 1/1/2024 onwards). That kind of metadata would need to be obtained from a setting somewhere, either a field setting or a future setting for this formatter. Either way, the low level formatter wouldn't know.

    Worth looking at in the context of #3445445 and work done to support single-value datetime and timestamp fields. Handling optional end dates is a relatively minor extension of that.

  • Merge request !4Patch #10 β†’ (Open) created by karlshea
  • πŸ‡ΊπŸ‡ΈUnited States karlshea Minneapolis πŸ‡ΊπŸ‡Έ

    Rerolled from patch #10 and added fix for date fields in the field formatter.

    • 3a0767f3 committed on 2.1.x
      Add tests for optional end date support (#2970628)
      
    • d4f3b641 committed on 2.1.x
      Add support for optional end dates (issue #2970628)
      
  • Status changed to Fixed 4 months ago
  • πŸ‡ΈπŸ‡ͺSweden erik.erskine

    #16 looks good - I've committed this, and added some kernel tests for it.

    Thanks everyone!

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

Production build 0.71.5 2024