Can ical4j identify exceptions to recurring calendar events?
See original GitHub issueI get an iCalendar file from an external source, over which I have no control, and in that file there are entries like these:
BEGIN:VEVENT
DTSTART;TZID=Europe/Zurich:20130511T051500
DTEND;TZID=Europe/Zurich:20130511T171559
DTSTAMP:20150822T121746Z
UID:06984C6F68C24922B235F7C4D5DDA98D00000000000000000000000000000000
RECURRENCE-ID;VALUE=DATE:20130511
CREATED:20120117T180152Z
DESCRIPTION:Event info particular to this occurrence
LAST-MODIFIED:20150516T235258Z
LOCATION:
SEQUENCE:3
STATUS:CONFIRMED
SUMMARY:A recurring event
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
DTSTART;VALUE=DATE:20150509
DTEND;VALUE=DATE:20150510
DTSTAMP:20150822T121746Z
UID:06984C6F68C24922B235F7C4D5DDA98D00000000000000000000000000000000
RECURRENCE-ID;VALUE=DATE:20150509
CREATED:20120117T180152Z
DESCRIPTION:Other event info particular to this occurrence
LAST-MODIFIED:20150509T093901Z
LOCATION:
SEQUENCE:2
STATUS:CONFIRMED
SUMMARY:A different summary for this occurrence
TRANSP:OPAQUE
BEGIN:VALARM
ACTION:AUDIO
TRIGGER:-PT15H
X-WR-ALARMUID:85257BF6-4591-4522-A479-706130730C65
UID:85257BF6-4591-4522-A479-706130730C65
ATTACH;VALUE=URI:Basso
X-APPLE-DEFAULT-ALARM:TRUE
ACKNOWLEDGED:20150509T093901Z
END:VALARM
END:VEVENT
BEGIN:VEVENT
DTSTART;VALUE=DATE:20120512
DTEND;VALUE=DATE:20120513
RRULE:FREQ=MONTHLY;INTERVAL=12;BYDAY=2SA
EXDATE;VALUE=DATE:20140510
DTSTAMP:20150822T121746Z
UID:06984C6F68C24922B235F7C4D5DDA98D00000000000000000000000000000000
CREATED:20120117T180152Z
DESCRIPTION:
LAST-MODIFIED:20150508T180631Z
LOCATION:
SEQUENCE:2
STATUS:CONFIRMED
SUMMARY:A recurring event
TRANSP:OPAQUE
CATEGORIES:http://schemas.google.com/g/2005#event
BEGIN:VALARM
ACTION:AUDIO
TRIGGER:-PT15H
X-WR-ALARMUID:16016C31-EE77-4551-8161-274745B1B7F8
UID:16016C31-EE77-4551-8161-274745B1B7F8
X-APPLE-DEFAULT-ALARM:TRUE
ATTACH;VALUE=URI:Basso
END:VALARM
END:VEVENT
So there is one VEVENT entry for a recurring event that happens year after year (this iCalendar file is old, and has accumulated a lot of cruft over the years) but from time to time someone has entered another VEVENT with exceptions to the DESCRIPTION or the SUMMARY of a particular occurrence of this recurring event.
Now I’m using ical4j to parse this file and produce a list of events, like this:
2015
- May 9: “Other event info particular to this occurrence”
At the moment, I’m doing this with a simple loop over all the VEVENT entries:
for (VEvent event : (Iterable<VEvent>) calendar.getComponents(Component.VEVENT)) {
for (Period period : (Iterable<Period>) event.calculateRecurrenceSet(year)) {
// ...
That works pretty well, except for in the case of the VEVENT entries listed above, which then show up duplicated, one item for the original recurring event and one other item on that same day for the event with the exceptions. (Software like Google Calendar, on the other hand, will notice that the entries have the same UID and only show the one with the exception.)
This leads to these two questions, to which I’ve not been able to figure out answers on my own:
- Is there any way in which I could use ical4j to identify these and resolve duplicates?
- If not, would this not be a reasonable feature request?
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (3 by maintainers)
Currently ical4j doesn’t de-dup components with the same UID, however I think that would be a valid feature request.
I’ve just added a new class: ComponentGroup. The idea is that Components with the same UID can be grouped together and treated like a single component.
Currently this requires explicit grouping like so (using above example):
PR is here: #167 Feedback would be appreciated, thanks.