Make fallback date format editable rather than hard coding to US notation

Created on 20 August 2020, over 4 years ago
Updated 19 January 2023, over 2 years ago

Problem/Motivation

Drupal has a "Fallback date format" which always uses the US notation: MM/DD/YYYY
With Drupal being used a lot in non US projects this is actually a problem since the fallback format can't be edited and is used when a format is not provided.

Example of a module not passing a date format in a date value: https://git.drupalcode.org/project/webform/-/blob/8.x-5.x/src/WebformSub...
In the above line:
($entity->{$name}->value ? $date_formatter->format($entity->{$name}->value) : '')
should be (for example)
($entity->{$name}->value ? $date_formatter->format($entity->{$name}->value ,'long') : '')

Steps to reproduce

  1. Install Drupal
  2. Visit: /admin/config/regional/date-time
  3. See that Fallback date format can't be edited and is using US notation.

Proposed resolution


    Updating steps based on suggestions from @alexpott on comment #22 Make fallback date format editable rather than hard coding to US notation Needs work
  • Unlock the fallback date format
  • Add special case the fallback ID and unlock it.
  • Update \Drupal\system\DateFormatAccessControlHandler::checkAccess() to cope with the new rules.
  • We'll also need to update \Drupal\Core\Datetime\Entity\DateFormat::sort() to treat the fallback as locked.
  • Add a constant on the DateFormat class that has the id string for the fallback.

Option 1 should be enough for everybody.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Feature request
Status

Needs work

Version

10.1

Component
Datetime 

Last updated about 17 hours ago

Created by

🇬🇷Greece bserem

Live updates comments and jobs are added and updated live.
  • Needs change record

    A change record needs to be drafted before an issue is committed. Note: Change records used to be called change notifications.

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.

No activities found.

Production build 0.71.5 2024