Specifying timezones for Calendar Events


(Andrew Harris) #1

Matrix Version: v5.5.0.2

Returning to an old favourite of mine - timezones!

We manage lots of events, and they often occur in different timezones. Sure, you can define the event in UTC time, and that’s solid, but then the display of the calendar event is wonky.

I’m building a tool to allow users to add an event to their calendar of choice. Easy enough for Google and Yahoo calendars (which recognise named timezones), but for .ics (Outlook/AppleMail) I need timezone definitions so that I can create a VTIMEZONE component in the output.

It seems to me as though this should be a built in tool in Matrix - there are plenty of php libraries that stay updated and handle this stuff. I’ve looked around and can find no reference to this in the manuals, and nobody seem to have any solutions.

Anyone ventured down this rabbit hole?


(Andrew Harris) #2

Hells bells! I just realised that Matrix doesn’t even handle Daylight Saving properly in your own time zone.

eg: Today, Aug 6. I created an event for 31 October at 10am - the backend shows 10am, the front end output shows 9am, but %event_start_time_ical% shows: 20191031T100000

It’s rather annoying.


(Bart Banda) #3

Hey woowoowoo! I assume this was the forum post you were talking about last week? :slight_smile:

Could you share the Paint Layout you use to produce your current .ics file on the frontend? Curious to see how it’s currently being done.

Hmm, this sounds like a bug. The frontend should show exactly the same as the backend. When you say “the front end output shows 9am”, what keyword are you using to output that time?

Also, if you are after outputting the local time with time zone reference, looks like you have to use TZID as per https://www.kanzaki.com/docs/ical/dateTime.html.


(Andrew Harris) #4

Hi Bart,
I already emailed an epic (via Andrew G, 'cause I found I didn’t have your direct email), but I’ll put some responses here for the record as well.

The paint layout I’m using is: #2776846 on cms.unimelb.edu.au - it’s a bit of a mish mash, but I get away with it because it is single purpose. Assets have a user specified design and paint layout, so URLs have
?SQ_DESIGN_NAME=ical&SQ_PAINT_LAYOUT_NAME=ical
appended.

The design is just:
<MySource_PRINT id_name="__global__" var="content_type" content_type="text/calendar" />
<MySource_AREA id_name="body" design_area="body" />
which initiates a download immediately.


For the incorrect time thing, I checked again, and it definitely looks like a bug:

In the Description field of my Calendar event, I have:
event_start_datetime: %event_start_datetime%
event_start_time_ical: %event_start_time_ical%
but my front end output is:
event_start_datetime: 30 Oct 2019 9:15 AM
event_start_time_ical: 20191031T101500

The first keyword event_start_datetime is returning the non-daylight savings time. You can see this on my asset: Across daylight savings #3147209.


Finally yes. TZID sets the timezone of an event, but an ical file is a complete self contained calendar.
The timezone needs to be defined at the calendar level or it doesn’t understand what you mean when you specify a timezone in an event. https://www.kanzaki.com/docs/ical/vtimezone.html

At the calendar level, you define all the timezones you want to use in a VTIMEZONE - a bit like classes in a css file. Then, at the event level, you can specify (with TZID) which timezone each event belongs to by name.
Just like CSS - if you refer to a TZID that you haven’t defined in the calendar, it’s just ignored.

The rules in a VTIMEZONE must include all the information required for the event to be defined. So, using my daylight savings example above - my VTIMEZONE would need to define AEST as +10 and AEDST as +11. Without both of these, it wouldn’t be able to make sense of me adding an event now (in a period not covered by daylight savings) for a calendar event in the future (in a period covered by daylight savings).

Horrible, innit?
You can see why a metadata schema just isn’t going to cut it. There are so many variables!

Cheers, Andrew


(Andrew Harris) #5

Holy cow!

I was just looking at those two outputs for the calendar event.
They are copy/pasted straight from the page… notice anything odd, apart from the hour difference?

Rewriting the ical output in the same format makes it clearer, so I added:
%event_start_time_ical^date_format:j M Y g\:i A%
to my output…

event_start_datetime: 30 Oct 2019 9:15 AM
event_start_time_ical: 20191031T101500
event_start_time_ical: 31 Oct 2019 10:15 AM

Yep, 25 hours difference. Hmm!


(Bart Banda) #6

Def looks like a bug, but I can’t replicate in the latest 5.5.3.2, so maybe it has been fixed since then? If you can’t get around it, worth sending a support ticket in to see if Squiz Support can help identify where the issue is.

In regards to the Timzone specification in the ical output format, have you tried putting the timezone data inside BEGIN:VTIMEZONE as per https://stackoverflow.com/questions/35645402/how-to-specify-timezone-in-ics-file-which-will-work-efficiently-with-google-outl ?


(Andrew Harris) #7

Oh, yes, and that will work, but when you start talking about keeping an up to date source of timezones for the world, so that an end user can select Asia/Singapore from a drop down menu, then you are talking significant complexity.
There is the official database source: https://www.iana.org/time-zones, but how can we mere mortals translate that into something usable in Matrix?