Support a per-instance "all-day" option for datetime and datetime range fields

Created on 26 May 2016, about 9 years ago
Updated 13 May 2024, about 1 year ago

Problem/Motivation

The Date module for D7 had a “all day”-option. A field could be created with a checkbox labeled “all day” and when checked, the time field was removed, and only a date field remained.

Many calendaring systems, including Google and Apple's native calendar, support this. It's a very common UI pattern, and makes life a lot easier for content editors.

Currently, core supports either a "Datetime" field, or a "Date-only" field, but not a single field where the time part is optional. Being forced to use 2 totally separate fields for this is a huge problem, because then views of events get all complicated and weird. "We" just want a single field, but some of the events have a specific time, and others are "all-day".

Proposed resolution

https://www.drupal.org/project/date_all_day now exists to try to solve this problem.

Basically, we need a checkbox on all date widgets for "all day". The default value of this checkbox can/should be a widget setting. If checked, the time elements of the field input should disappear, not be required, validated, etc.

How this should be stored in the DB is TBD. The two most obvious choices are:

A) Add a separate column to the value table.

B) Overload the existing datetime with special values that indicate "all-day" (e.g. time as 00:00:00 or something).

Remaining tasks

  1. Decide if date_all_day is the right approach.
  2. If so, turn it into a patch against core.
  3. If not, figure out the right approach and implement it. This includes deciding on how the all-day bit should be stored with each field value.
  4. Write / update a lot of tests.
  5. Review/revise/repeat.
  6. Commit.

User interface changes

- New widget settings to control all-day behavior (should it be allowed as an option, and if so, what the default should be).
- If so configured, new checkbox on datetime* field widgets (e.g. on entity forms).
- Changes to field formatters that take all-day into account for how a given date value is displayed.

API changes

TBD.
Perhaps changes to the datetime form Element.

Data model changes

TBD.
Maybe none.
Maybe a new column in the schema to store datetime fields.

Original report by rolfmeijer

The Date module for D7 had a “all day”-option. A field could be created with a checkbox labeled “all day” en when checked the the time field was removed, and only a date field remained. In the db the time entry was written as 00:00:00.

I’m not sure this is still the best way to build a function like this (as you could not have a date with the time set to 00:00:00 because that would mean it is a “all day”-date), but it would be nice to be able to make the time field optional when a date-type of date-time is chosen.

Are there any plans to bring this functionality to D8 core, or should this be made available as a contrib module?

Feature request
Status

Needs work

Version

11.0 🔥

Component
Datetime 

Last updated 1 day ago

Created by

🇳🇱Netherlands rolfmeijer

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

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

  • Usability

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

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.

Production build 0.71.5 2024