Problem/Motivation
1. A date ecosystem module that is being increasingly adopted in Drupal is https://drupal.org/project/smart_date . This module provides its own field type, smartdate. Although the 3.x version of this module provides support for the Drupal core daterange field for non-recurring date instances, its implementation for recurring date instances only supports its smartdate field type.
2. Although the module provides some robust date formatting configuration, Smart Date does not currently support AP date style formatting directly. Rather than adding AP date style as an additional formatter to that module, it would be most efficient to add a minimal amount of logic in the Date AP Style module to be able to render fields of type smartdate in the range formatter.
Proposed resolution
1. Add field formatter annotation to specify that the daterange_ap_style formatter supports the smartdate field type.
2. Add logic that parses the entity schema of the smartdate field type to derive the start & end timestamps.
Alternative considered: add a new field formatter to Smart Date that would extend the field formatter provided by Date AP Style to support smartdate field type. The disadvantage with this approach is that it would have an explicit dependency on the Date AP Style module (this could be made opt-in by bundling the AP-style formatter in its own sub-module in Smart Date that has a dependency on Date AP Style, but that doesn't seem ideal). In contrast, the proposed resolution makes the dependency implicit, supporting the field type smartdate in the Date AP Style range formatter.
| Comment | File | Size | Author |
|---|---|---|---|
| #27 | 3167284-interdiff-26-27.txt | 4.12 KB | joegraduate |
| #27 | 3167284-27.patch | 9.03 KB | joegraduate |
Issue fork date_ap_style-3167284
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
mark_fullmerComment #4
mark_fullmerSetting back to "Needs review" -- testbot marked this as failed, though there are no tests, and the code standards problems identified are not introduced by the patch.
Comment #6
shelaneComment #7
shelaneI am reverting this patch because it caused an error for the core date range:
Though I know I need tests, this will now especially need a test in order to ensure that both date type formatters work.
Comment #13
trackleft2OOps, looks like one review in gitlab makes 1000 comments here:
Made a MR for adding a field type parameter that we can check to make sure we are looking at smartdate.
https://git.drupalcode.org/project/date_ap_style/-/merge_requests/2/diff...
Additionally fixed the smart date ALL DAY functionality.
Comment #14
trackleft2Comment #15
trackleft2Here's a patch against version 1.0
Comment #16
trackleft2OK, it looks like I had the logic slightly wrong in #14 and #15, here is a better one that works now.
To use
Enable Smart Date
Create a field that uses smart date range
Add the field to a node type
Create a few new pieces of content using that node type
Test 1 Start date filled out, "All day" box filled, End date set.... No time entry necessary.
Test 2 Start date and time filled out duration field with 0 value
Test 3 Start and end date and time filled out,
Test 4 Start date filled and start time 12:00 PM Midnight on start date.
Sorry for all of the noise while I figure this out.
Comment #17
Shoshana Mayden commentedTested this patch locally with an event content type using smart date and ap style together. It worked as expected for me.
Comment #18
trackleft2It seems there is still a minor issue with smart date displaying noon and midnight even when those boxes are not set.
Comment #19
shelane@trackleft2 How would you like to handle the noon and midnight? Merge this and make that a separate issue or wait for a fix?
Comment #20
trackleft2@shelane, I'll work on getting a fix in tomorrow, thanks for checking.
Comment #21
shelane@trackleft2 feel free to commit it when you feel it’s ready.
Comment #24
joegraduateUpdated
3167284-support-smart-datebranch in issue fork with commits from issue fork's8.x-1.xbranch and rebased on the latest project8.x-1.xbranch and then re-opened original MR !1 (because working with the issue fork's8.x-1.xbranch was awkward/confusing. Also added some minor whitespace cleanup commits.Also adding a patch file (generated from MR !1 branch) that can be used in composer builds for testing.
Comment #26
joegraduateSetting back to Needs review since no tests (or tests failures) exist.
Updated patch with fixed syntax error.
Comment #27
joegraduateUpdated patch with PHPCS fixes.
Comment #29
joegraduateNo tests exist so there were no actual failures.
Comment #31
shelane