For calendar views, if I use the {{ time }} variable, it will output something like this for multi-day events with start/end times…
Oct. 1, 8 a.m. - Oct. 3, 5 p.m.
Is there an equivalent format variable for widgets? The {time} var shows a different time for each day of the event. So for the example above…
The first day shows a time of 8 a.m.
The second day shows a time of all day
The third day shows a time of 12 a.m.
I want to be able to output the exact same string as the calendar view above, but in an event widget, for every day of the event. I just can’t find any combination of format vars that will accomplish that.
Thanks for raising this – totally see the use case here, and I had hoped to find an easier answer for you than I have. The “Oct. 1, 8 a.m. - Oct. 3, 5 p.m.” timespan we show on the front-end calendar is assembled with JS when that view loads, and translating that to a widget output is much more involved than I anticipated.
I had hoped to pilot something for core for this, and barring that, maybe something that could be thrown into a custom module for testing – but the wide ranging implications of start/end repeat dates, timezones, years, etc, ended up snowballing so I don’t have much of anything useful to offer at the moment, unfortunately.
Other than this: we’ve got this filed on our roadmap and I’m hopeful we can revamp {time} or offer a new alternate “full datetime” variable to events widget between now and the 3.0 release.
I forgot about this. After I posted this question, I made a custom module that serves my purposes.
Actually, I just added onto an existing custom module I had created a while back that adds some extra variables to event widgets. These are the custom vars I had previously added:
is_all_day - pull this from the database and add it as a widget format var
is_multi_day - pull this from the database and add it as a widget format var
start_date - parse date_dt from the database and add it as a widget format var
end_date - parse date2_dt from the database and add it as a widget format var
Those have been working well for a while. So I just added these:
custom_start_time - again, parse date_dt from the database, but this time just get the time
custom_end_time - again, parse date2_dt from the database, but this time just get the time
All of these extra vars allow me to do some more complicated <field> logic in widgets, such as:
<field content="true">
<!-- LW: for multi-day events that are **not** all-day events -->
<if var="is_multi_day"/>
<if var="is_all_day" value=""/>
<!-- LW: show time + ending date/time -->
<content>
{time} - {end_date}, {custom_end_time}
</content>
<else content="true">
<!-- LW: for all other events, just show the time -->
<content>
{time}
</content>
</else>
</field>
I am looking forward to a simpler native solution, though.