This module does not work for date fields that store the data as ISO format or Unix Timestamp format (See https://drupal.org/node/1455576 for explanation of the different date formats available).
When the module prepares the about-to-be-saved node for comparison, it loads its date field start and end time into new DateObjects, and are ultimately converted to DATE_FORMAT_DATETIME (Y-m-d H:i:s). When the query is built to compare the nodes start and end times with other nodes in the database, it does a BINARY comparison of the date fields - which means it does a byte-for-byte comparison.
So unless the date fields are actually stored in the format "Y-m-d H:i:s", then the comparisons will never work properly, and the only Date field type that stores them like that is the standard one called "Date", not ISO or Unix.
This module should provide enough flexibility to compare all three supported date types. I'll see if I can dig in further and come up with a patch.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | reworked_date_comparison-2180903-1.patch | 6.18 KB | bkosborne |
Comments
Comment #1
bkosbornePatch attached.
It mainly avoids any type of date conversion of the date fields, so now comparisons of all three types of date fields work. These are Date (default), Date (ISO), and Date (UNIX). I tested each of the three and made sure the conflict detection works properly.
I found that the BINARY conversions were introduced in #1871378: Repeat dates are not checked for conflicts [D7], and I was able to remove them after I converted the static query to dynamic query, which addressed the problems raised in that thread.
I also reworked
_resource_conflict_get_overlapsto make the code more efficient, tho the conversion to a dynamic query may have negated it anyway (dynamic API is slower in Drupal). There was also a bug in this function where the $nids would get overridden for each $conflict_type that was iterated over.Comment #2
bkosborneErrr don't think anyone is going to review this =/
Committed. Thinking of writing some tests for this.