Problem/Motivation

Enabling the 'Show "All Day" instead of midnight' field formatter setting breaks the display of start/end times for non all-day date values.

This definitely affects Smart Date fields but it seems other Date fields may be affected as well.

Steps to reproduce

  1. Add a smart date field to an event content type
  2. Configure the field to use AP Style field formatter with the "Show 'All Day' instead of midnight" field formatter setting enabled
  3. Create an event with a start and end time (do not check "All Day")
  4. View event and see no start/end times displayed.

Proposed resolution

Fix the condition block that hides the time when the "all day" field formatter setting is enabled.

Command icon 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

trackleft2 created an issue. See original summary.

joegraduate’s picture

Title: When use all day selected, time doesn't display unless all day conditions are met. » Show "all day" field formatter setting not working correctly
Issue summary: View changes
Status: Active » Needs review
trackleft2’s picture

StatusFileSize
new1.2 KB

New patch with minimal changes to fix the issue.

joegraduate’s picture

Although I think the refactoring changes included in @trackleft2's MR are good improvements, they may be better to address in a separate/follow-up issue. It would also be good to add a test for this regression.

I think the simplified patch in #4 would probably be good to get committed ASAP, if possible.

joegraduate’s picture

FWIW, it looks like this regression was introduced with the changes made for #3167284: Support Smart Date field type in RangeFieldFormatter.

joegraduate’s picture

StatusFileSize
new1.2 KB

Looks like the patch in #4 is missing a new line at the end of the file. The attached updated version should apply cleanly.

Status: Needs review » Needs work

The last submitted patch, 7: 3272760-7.patch, failed testing. View results

joegraduate’s picture

Status: Needs work » Needs review

No actual tests exist so setting back to needs review.

mark_fullmer’s picture

I can confirm that the patch in #7 fixes the missing time on our Drupal distribution, which uses Date AP Style in conjunction with Smart Date. I used our site's demo content to verify that the time displays correct on multiple date variation, including recurring events.

I also follow and agree with the logic change in #7's patch.

I'd need to spend more time going through the more substantial business logic changes in the merge request. Aside from the syntax cleanup and abstractions into helper methods, is there a different date rendering scenario that the merge request is addressing that is not covered in #7?

trackleft2’s picture

@mark_fullmer the end result of the $time_output variable is exactly the same between the patch and the merge request.

I think we should probably use the pattern used in the patch in the merge request, since it is a bit simpler to understand.

The main difference between the merge request and the patch is that the merge request returns earlier once the output is determined to be an "All day" string.

mark_fullmer’s picture

Status: Needs review » Reviewed & tested by the community

I am in support of the implementation proposal in #11. Confirming once again that this works with the latest version of smart_date `4.0.x` (as of 2023-07-20).

Setting to "Reviewed and tested by the community."

shelane’s picture

Chris@trackleft2, I’m a little lost in what you’re saying in #11. Can you commit the implementation you think is best?

  • shelane committed f5c21cec on 8.x-1.x authored by trackleft2
    Issue #3272760 by trackleft2, joegraduate, mark_fullmer: Show "all day"...
shelane’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.