To clarify - this post is in support of getting an improved standard for handling dates and times into core. In my opinion, with the extendability and prevalence of other modules that rely on this - calendars, scheduling, office hours, registrations/booking, etc. - a core standard is warranted and would be exceedingly useful to the community.
As an intermediate developer reviewing many of the current modules and issues regarding the handling, etc. of dates currently seems a bit wild west. And I think a standard, best practices (performant) storage and basic ui functionality in core would allow for cleaner, more coherent coding and discussions, more inherently compatible projects, and be just another feather in the cap to tout d8/d9's modern utility.
I'm really excited about the traction and attention date and daterange functionality and support are getting and the responsiveness of the community.
There are some great discussions happening, and I thought I'd make an issue to highlight the issue(s) and connect some of these dots of insight.
I'm referencing several issues that I've added as related issues in the information below.
The relatively new smart date module is gaining attention and is very performant with a clean, easy-to-use user interface.
My primary point of concern with this module is that it's stored using timestamps instead of native date formatting. This excerpt by dpi explains this concern quite well (from this issue: Integrate Recurring Dates Field with Smart Date)
...timestamps aren't particularly a great storage format for dates. They are subject to integer issues, both within the database and in apps themselves. Mysql, et al have native support for date formats, and scale appropriately, including the native facility to handle timezone changes, date math, and potentially any year number (esp. pre 1970, in the case of unix timestamps).
That said I'm not 100% on board with Drupal's format either, as it assumes UTC. However, it is better than timestamps.
One of the core concerns solved by Smart Date listed on the project page: (#3048072: Date Range field creates very slow queries in Views) is a fundamental problem with the way that the views plugin works. It should not be doing bulk date math on the database end, instead inputs and outputs should be normalised so database math is not necessary. This views plugin should be rewritten.
Additionally, this different storage method means smart date isn't compatible with most of the other date/calendar/scheduling modules currently - including recurring dates, datetime extras, I assume other modules such as office hours, and the various calendar modules:
In reviewing the wealth of information out there, I think the underlying issue is with Drupal's need for a more robust adoption and support of db native datetime fields. As dpi notes again:
Dont mean to rock the boat too much but I think the ideal situation would be to unify core date field into one that is a standard db-recognised date format, not on the format DR extends apon, or an integer timestamp.
There is probably a long dead discussion about this, but I'd like the date item field to be ISO8601 with any time zone, not just 'Z'. Or whatever format includes time zone that is commonly recognised across DB implementations.
Particularly, this issue by mandclu, the maintainer of smart date, seems to be a fairly important issue that warrants attention and solution to fit in with a larger, standard, extended date feature in core.
As referenced above, I think this last holdout for a well supported, performant, and user-friendly date/daterange/time system is the primary blocker for better Drupal-supported calendar, scheduling, registration and other systems.
Original ISO Date format discussion - as referenced by Mandclu below
Summary of Date in Eight initiative
Comments
Comment #2
w01f commentedComment #3
w01f commentedComment #4
w01f commentedComment #5
mrpauldriver commentedDrupal 8 has been a difficult experience for any website requiring dates and calendars. And with Drupal 9 being just around corner, we may face an extended period of difficulty unless this is resolved once and for all.
Everyone effected knows this, but efforts to coordinate seem to be fragmented and short of resources.
For now, I am sticking with date_recur and its complementary widget modules, as this is the most usable solution.
Comment #6
mandclu commentedThanks for raising this. I had originally intended for Smart Date to be only a widget, to be used with the core Date Range module, but decided to make it a completely new field type after observing the impact on performance of having the values stored as strings. You may also want to refer to #2366213: Date field doesn't use database-native date storage and the other issues that it, in turn, refers to, as they give a good sense of the discussions that brought us to the current state.
Comment #7
w01f commentedComment #8
mandclu commentedFor some reason I can't seem to set the original storage discussion directly as a related issue. I wanted to, because that's where the decision was made to only support dates stored as varchar, in an ISO standard format.
A couple of other clarifications:
I completely agree that core should support additional date storage options, especially the native datetime storage fields. I understand the argument about complexity, but we've pushed the problem downstream, so contrib authors are trying to find their own solutions. I understand and appreciate the idea of trying to keep an option open for sites using an RDBMS that doesn't have a native datetime field, but that's why we should leave the current storage as an option, but also let site builders that don't need the portability choose an option that is specifically designed and optimized for the very problem they're trying to solve: efficient handling of dates and time. Honestly, if there's one thing I would like to see Drupal 9 get right, it's this.
Let's be honest, the argument about simplification is oversold. Most contrib modules that are designed to handle arbitrary date fields already have to anticipate dealing with varchar/ISO date fields, or timestamps, as both are in core. The idea that it's somehow an unreasonable burden to also support a third option simply doesn't ring true for me.
Comment #9
w01f commentedComment #10
mpdonadioBeen out of the loop for a while now, but the thing that has been keeping me from core dev is starting to wrap up.
Datetime storage has a long history, dating back to the Drupal 7 Date module, and the first patch to get datetime into core, as noted above.
Timestamp fields were really supposed to be internal-only fields (or base fields). I am not terribly happy that they got put back into the UI, as it does cause fragmentation and code duplication.
There is a longstanding issue, #2716891: DateTimeIso8601::setDateTime() vs. DateTimeItem::schema(): (at least) one of them is broken, to update storage to reflect the UTC offset as part of storage (note that the +HH:MM portion is not the timezone, it is the offset from UTC for that particular timestamp which takes into account the timezone for a particular place and any seasonal/religious adjustments). The fix itself is easy; the update path is a beast. There is also an issue to store the IANA TZ name in storage along with the ISO8601 string.
Personally, I am against letting users pick storage methods like they could in D7. But, I think looking into backend specific storage is good, as long as the API advertises something consistent. I think there are three parallel paths that can be taken.
1. Look into the DB-specific storage options, with varchar as the default.
2. Improve the FieldItem API for datetime, similar to what the REST normalizers do, so setting values can be flexible and internally convert to the storage format, and getting values will convert to the full ISO8601 string. This is a potentially stopgap until #2716891: DateTimeIso8601::setDateTime() vs. DateTimeItem::schema(): (at least) one of them is broken gets figured out.
3. Encourage people, better document, and potentially improve API and/or internals, to get people to use the computed DDT object instead of the value string.
Comment #11
mpdonadioComment #12
dwwAdding some related issues:
#3064357: Join forces and reduce duplicate effort? is where I'm discussing smart_date with the maintainer and trying to increase collaboration and reduce fragmentation.
#3064640: Provide alternate storage backends for native DB date fields is about trying to support DB-native date storage for core datetime and daterange fields inside datetime_extras (as proof-of-concept for something we could hopefully move into core).
Cheers,
-Derek
Comment #13
dww@mandclu: Re: #8 -- that's because the original discussion you're linking is on groups.drupal.org, not an issue on d.o, so it can't be officially listed as a "related issue". At least #2366213: Date field doesn't use database-native date storage is already in the list.
Comment #14
daffie commentedBig + 1
Comment #23
mc0e commentedIs this still alive? Did the discussion move somewhere else?
Comment #24
mortona2k commentedI'd say not much has changed, except for Smart Date rising in popularity and being included in Drupal CMS.
A big hangup is module support for Datetime vs Smart Date vs others like Recurring Dates Field, Year Only, etc. So I doubt core will change any time soon.
Defaulting to using Smart Date is a relatively safe bet. Otherwise, you still have to experiment to find the right combination of date storage, widgets, and module support.
Comment #6 still stands. I don't know if anything has changed on the database front to make a difference on storing timestamps vs native date fields.
Comment #25
mc0e commentedIf I use Smart Date, what options do I have for producing an iCal feed, or CalDAV?