Can't hide "all day" and only show start times in a view

Created on 9 May 2023, over 1 year ago
Updated 24 May 2023, over 1 year ago

Problem/Motivation

(I don't think this is a bug, since it works in the way it says it works, so I'm marking it as a support or even feature request.)

On D10.08, using Smart Date 4.0.2 and Calendar View 2.1.1, I want to show a calendar with only the start time for timed events, and hide the "All day" text for All-day events. But I can't figure out a config arrangement to allow that.

I've created a calendar month view with just the Smart Date field and the Title field showing for my Event content type. I've set up a new Smart Date format similar to the out-of-the-box Time Only format, just changed leave the "All day" text blank. That's great.

But with the Smart Date Formatter options in a view, the "all day" text doesn't kick in unless both "Start" and "End" are chosen in the "Time Parts" set. If I choose both of those, then those events with a start and end time show those times, and the all-day events simply show the Title field. The latter is what I want, but the former isn't.

But if I choose only "Start" in the Time Parts, then the all-day events show "12:00am". Strictly speaking, that's correct module behaviour, since that is the start time of an all-day event. But I don't want that to show on those events.

One workaround is that the start and end time of an event can be the same. Then, with both "Start" and "End" checked in the Time Parts set, only the start time is shown on those non-all-day events, and the all-day events have "All day" hidden. But this only works if no Event has a duration. I want some events to have a definite duration, I just don't want to show that in this particular Calendar View view.

Steps to reproduce

  1. Create both timed and all-day Events.
  2. Create a Calendar View view and populate it with Events (Date field is a requirement, so that it can be checked in the "Date field" setting in the "Calendar by Month" format provided by Calendar View module.
  3. Check only "Start" under Time Parts.
  4. All-day events will then show a start time of 12:00am.
  5. (Or, check-both "Start" and "End" under Time Parts.)
  6. ("All-day" will now correctly disappear, but all Events that have a duration now show both Start and End times.)

Proposed resolution

Not sure. Is there a way to key the visibility of the "all-day" text on whether "All day" is checked on the node creation form rather than on the start and end times? Or can the logic for All-day events still evaluate on both the start and end times even if only Start is chosen in the Time Parts set in the view?

Or maybe I'm missing something and this behaviour is already possible, and just need that pointed out to me.

Thanks in advance for any insight.

💬 Support request
Status

Closed: works as designed

Version

4.0

Component

Calendar integration

Created by

🇨🇦Canada michaelschutz

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @michaelschutz
  • 🇨🇦Canada mandclu

    Theoretically it might be possible to create a views filter along the lines of "is all day" which sounds like it would accomplish what you want. The big downside is that it would be very slow.

    I would suggest adding a calculated field to store this value instead, and then filter on that in your view.

    The smart_date.manager service has a method you could use to make this calculation:
    public static function isAllDay($start_ts, $end_ts, $timezone = NULL)

    The above will return a boolean.

  • 🇨🇦Canada michaelschutz

    Much appreciated mandclu. I may be out of my depth here, but I'll start there and see what I can make happen.

    I don't actually want to filter the view to show only all-day events, so I'm not sure a filter would work anyway. I just want to "filter" the visibility of the "All-day" text. But if I can get a boolean for that in a calculated field, then I could use Twig to conditionally hide the Date->Start field. Thanks for pointing me in a helpful direction.

  • Status changed to Closed: works as designed over 1 year ago
  • 🇨🇦Canada michaelschutz

    Just circling back to close this loop...

    I went with the super-simple option of using Twig in the field rewrite box to evaluate the start time string - i.e. {% if field_event_date_value != "12:00am" %}

    Probably not the best way to do it, but with my limited time and skill, it works. :)

    Thanks again.

Production build 0.71.5 2024