Problems with Sitefinity Event Dates

I’ve hit quite a few issues while building a page that displays events in Sitefinity using just the out-of-box functionality. Along the way, I’ve logged a few support issues, but I decided to write it up from beginning to end to clear my mind and hopefully save others from getting stuck with similar problems.

Event Creation Scenarios

The following three scenarios capture what I think are the most common types of events that would be created in Sitefinity.

  1. An event at a specific date and time.
    User action: Set event start date and time.
  2. An event on a specific date.
    User action: Set as all day event, and set event start date.
  3. An event with a starting and ending date.
    User action: Set as all day event, and set event start and end date.

The good news is that the third scenario works flawlessly. The first two scenarios, however, do not.

Is the Event End Date Required?

To give the previously described scenarios some context, the event end date is an optional field, while the event start date is required; so there is clearly a “by design” expectation that events do not need an end date. To support the assertion that “no event end date” means an event takes place on the event start date and does not continue forever, consider the following:

  • I have exchanged with the support team an issue related to the event end date, and after consulting with the development team, they acknowledge and agree with this thinking.
  • The EventsDate field used in the event list view templates displays the event date information correctly when no end date is specified, e.g. “17 Mar, 2014” – a single day event.
  • Consider usability – content authors are not going to intuitively think that the event date field should be supplied when entering an event that occurs on a single day only (see scenarios 1 and 2 above).

Things Break Without an Event End Date

Unfortunately without an event end date, two very bad things happen:

  1. The calendar view of the event widget will display the event as continuing from the start date indefinitely (Support team agreed this was a bug and logged it in the feedback portal, but it might be years before we see a fix).
  2. The event timeframe options under “Which events to display?” in the events widget designer includes the options “Current events only”, “Past events only”, and “Upcoming and current events”. Selecting any of these will exclude events without an end date from the results (see the code in Telerik.Sitefinity.Modules.Events.GetEventStatusQueryItems to understand why)

These are significant failures.

What To Do?

Until these issues are worked out, my workaround is:

  • Train users to always provide an event end date for every event.
  • Replace the EventsDate field used in the default templates with a custom implementation.

Yes, that means entering things that seem quite wrong, such as this scenario 1 example:

image

Watch Out For All Day Events

If you decide to take this approach and implement your own code for displaying event dates in the front-end, be wary of the “All Day” checkbox (AllDayEvent property):

  • Start date is returned with a time of “00:00:00” and end date with a time of “23:59:59”. So you must not call ToLocal() or ToSitefinityUITime() before displaying them because (depending on your time zone) this will shift the start date into the previous day.
  • Even when the event end date is not given a value, the EventEnd value will be returned as the start date with a time of 23:59:59.

What should Telerik Do To Fix The End Date Problem?

I would like to see a check box beside the “Event end” input called “Same day”, which is checked by default. When checked, it will still be possible to enter the time part in the event end field, but the date part is synchronized with the event start date.

image

I wouldn’t persist this flag to the saved event data. Instead, the “Same day” setting would just be used to set and save the event end field value in the UI, and the resulting end date would be persisted. When loading an existing event for editing, the “Same day” setting will be automatically checked when the event start and end date parts are the same. In the back-end event listing view, some modifications should be made so that the value displayed in the event end column indicates it’s meaning rather than the literal stored value.

The Sitefinity version upgrade process should set event end dates to the same as the event start for all events that don’t have an end date value. That fixes existing data, unless of course somebody intended an forever occurring event, which seems quite unlikely. There might be some breakage on custom code written against the event date fields, so this should be called out in the release notes.

1 thought on “Problems with Sitefinity Event Dates”

Leave a Reply

Your email address will not be published. Required fields are marked *