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 ?