iCalendar, UID and Google Calendar |
2008-01-22
|
This weekend, with the help of Zaheer, I was trying to write an application that calculates the bonus for our support guys.
The idea is pretty simple. We have one Google Calendar in which they assign themselves support duty. The idea is that every moment is covered and no shifts overlap. They put their name in the summary, and that's it.
Another calendar contains "factors" - support duty on Christmas has a higher factor than during the day.
So, the idea was to write something that scans both calendars, counts each person's support duty, totals them, and prints out what we should be paying them. Simple enough, no ?
After a bunch of hacking and rewriting, I've come to realize that I don't really understand what the goal of UID: in the iCalendar RFC is.
Specifically, this UID is supposed to be "globally unique" to the creator of the event.
Now, in our case, I'm getting an ics file from the Google Calendar that contains entries with duplicate UID's. After some experimenting, I nailed it down to the following sequence of events:
- create a new calendar
- create a two-hour event on monday, ask it to repeat all weekdays, and have the rule be active for only a week - scheduling 5 two-hour events
- now move the first instance of this event one hour down. It might or might not ask you to update all events in the series - choose to update only the one event
Visually, you now see the first event at a different start time, and the other four as they were.
Now, export the calendar - download the private ics URL. The ics file contains two events. Both have the same UID. One event is the first instance, which was moved. The other is a recurring event as you defined it originally - including the first event as it originally was!
So, Google Calendar seems to think that the first entry for the first instance is somehow more specific than the recurrence rule, so does not consider the recurrence rule to apply on the first day.
I tried importing the ics in Evolution - as I expected, it only shows the first event, and none of the instances of the second (recurring) event. I think this is correct behaviour, in the sense that it ignores additional events with the same uid.
So, any iCalendar experts out there that can comment on what's going on and how my program can detect that it should not schedule an instance of a recurrence rule on a certain date, because some other event has the same UID ?
Yeah, I wouldn’t rule out Google Calendar bugs – I’ve noticed a few myself. The one I get most consistently (though, to be fair, rarely) is duplicate SMS event notifications. I’d set a notification on an event, then later change the event date/time, and end up getting SMS messages for both times. That could have been fixed at some point – I don’t think they publish changelogs.
Comment by Travis Reitter — 2008-01-22 @ 02:29
UID doesn’t guarantee a unique event instance (only unique creation). UID + RECURRENCE-ID does guarantee a unique event instance. You’ll notice in the scenario that you posted that there are two VEVENTs in the basic.ics. Each of the VEVENTs has the same UID, but different RECURRENCE-ID. You’ll also notice that the second has a recurrence rule (RRULE).
Thus, Google Calendar is right and Evolution is wrong. FYI, Sunbird/Lightning gets this wrong too.
Comment by npmccallum — 2008-01-22 @ 05:11
Yeah, painful world the one of the calendar recurrences :-( But as rpmccallum says, this is the correct behavior, the detached instance needs to contain the UID of the original VEVENT to keep the relationship between them, so that you can, for instance, remove all recurrences of that event in Evolution. The difference between the 2 VEVENT’s is the RECURRENCE-ID
Evolution, when we wrote the recurrence code, used to do the correct way, showing all recurrences, so if it does not do that now, file a bug.
Comment by Rodrigo Moya — 2008-01-22 @ 13:46