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
- Decide if date_all_day is the right approach.
- If so, turn it into a patch against core.
- 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.
- Write / update a lot of tests.
- Review/revise/repeat.
- 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?