[PP-1] Make the relative default value validation more forgiving towards deviating time zone notations

Created on 12 March 2025, 26 days ago

Problem/Motivation

Follow up for an issue that was identified during 📌 Drupal Usability Meeting 2024-11-15 Active and initially raised in 🐛 Better handling of timezones for relative default date + times Active .

It is currently not apparent that a timezone is set per default for the Relative default value field, 🐛 Better handling of timezones for relative default date + times Active is changing that default timezone to UTC, nor is the time zone that is applied communicated in the title or the description of the Relative default value field. In consequence it is not necessarily clear to the user that a time zone could be entered in the first place and that a certain syntax has to be met. How things are communicated to the user should be covered in another issue (I’ll add a link after i've created the other follow up issue), the issue here is about the behavior of the date field in regard of the various different ways time zones could be entered. The problems we’ve noticed are:

  1. If you add a relative date and time with a time zone, that time zone has to meet a specific syntax, other wise you run into an unspecific validation error: The relative date value entered is invalid.. The relative date has to be for example +2 Saturday 13:00 America/New_York, any deviation for the timezone like for example america/new_york, America / New_York, or America/New York causes the validation error. Plus based on the error message and/or the field description it is not clear at all which part of the entered relative date value +2 Saturday 13:00 America/New York is invalid.
  2. If you are adding a GMT or UTC time zone instead, there is no form validation error at all, no matter if you are using for example gmt+5, Gmt+5, GMT+5, utc+5, Utc+5, or UTC+5. Problem is, only for GMT+5 and UTC+5 the default relative time is shown on the corresponding node edit form of the content type, for any other case variant the date and time field remains empty.

Steps to reproduce

  • Go to admin/structure/types/manage/article/fields
  • Add a date field
  • On the date field settings page tick the “Set as default value” and pick “Relative date” as the “Default date”, and enter for example +2 Saturday 13:00 America/New York, and submit.
  • After running in a form validation error, change the default relative date to +2 Saturday 13:00 gmt+5 and go to node/add/article
  • , you will notice an empty date and time field, missing the set relative default date value.

Proposed resolution

If technical possible make the form validation more forgiving. In case spaces and/or different cases are used on the time zone of choice it should be still recognized, no form validation error should turn up, and ideally the time zone should be adjusted to the correct syntax - otherwise provide at least a more helpful and specific error message for the form validation error. If the adjustment to the correct syntax would be possible that would possibly solve the problem of the empty date and time fields on the node edit form as well - otherwise make sure that the date and time fields remain populated with the set relative default value nevertheless.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

11.0 🔥

Component

datetime.module

Created by

🇩🇪Germany rkoller Nürnberg, Germany

Live updates comments and jobs are added and updated live.
  • Usability

    Makes Drupal easier to use. Preferred over UX, D7UX, etc.

Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024