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

Created on 26 May 2016, over 8 years ago
Updated 13 May 2024, 8 months 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 6 days 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.

  • 🇵🇱Poland gugalamaciek

    Improved patch which covers:
    - adds all_day column in DB for datetime range fields. Set it as disabled for all existing data with datetime type
    - allow to enable all day dates for datetime type & set default value for it in field settings
    - widget to set all day, making sure that date is stored in UTC when all day is selected (in general timezone is ignored when all day event is set)
    - GraphQL - share allDay property for datetime range fields
    - formatter - for now only supported inn default formatter. You can specify date format for all day and non all day dates
    - js - when you'll select all day, time is set to 00:00:00 for start & end dates

  • First commit to issue fork.
  • 🇵🇱Poland gugalamaciek

    #50 is #49 extended with End date optional #153 ( https://www.drupal.org/project/drupal/issues/2794481#comment-14839868 Allow end date to be optional Needs review )

  • 🇮🇳India sakthi_dev

    @gugalamaciek, could you please share the diff. I have created an MR for 11.x 2ith #49.

  • Pipeline finished with Failed
    8 months ago
    Total: 195s
    #171445
  • 🇵🇱Poland gugalamaciek

    Ups... I forgot about schema updates. So this is #49 + schema fixes.

  • 🇵🇱Poland gugalamaciek

    @sakthi_dev I'll try to produce 11.x version in free minute... but can't promise when exactly.

Production build 0.71.5 2024