Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can an ICS file be written for a recurring event?

I want to create an ICS file that describes a recurring event, an event that takes place every Monday from 13:00 to 14:00 UTC for all of 2016. The ICS file should be importable by Google Calendar. I have found it difficult to find and understand details online about how such a file could be constructed. What I have currently is a way of creating a file that contains a list of individual events, but I want to have a rule for the events defined in the file instead. I have something like the following right now:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//SERN//INDICO//EN
BEGIN:VEVENT
SUMMARY:Software Meeting
DTSTART;VALUE=DATE-TIME:20160818T150000Z
DTEND;VALUE=DATE-TIME:20160818T160000Z
DTSTAMP;VALUE=DATE-TIME:20160912T165700Z
UID:[email protected]
DESCRIPTION:https://indico.sern.ch/event/999999/
LOCATION:42-3-002 (SERN)
URL:https://indico.sern.ch/event/999999/
END:VEVENT
BEGIN:VEVENT
SUMMARY:Software Meeting
DTSTART;VALUE=DATE-TIME:20160825T150000Z
DTEND;VALUE=DATE-TIME:20160825T160000Z
DTSTAMP;VALUE=DATE-TIME:20160912T165700Z
UID:[email protected]
DESCRIPTION:https://indico.sern.ch/event/999999/
LOCATION:42-3-002 (SERN)
URL:https://indico.sern.ch/event/999999/
END:VEVENT
END:VCALENDAR

EDIT: Following the solution provided by zcontent, I wrote the following ICS file that appears to work successfully:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//SERN//INDICO//EN
BEGIN:VEVENT
SUMMARY:Software Meeting
TZID:Europe/Zurich
DTSTART:20150202T170000
DTEND:20150202T180000
DTSTAMP:20150202T170000
RRULE:FREQ=WEEKLY;UNTIL=20380119T000000
UID:[email protected]
DESCRIPTION:https://indico.sern.ch/event/999999/
LOCATION:42-3-002 (SERN)
URL:https://indico.sern.ch/event/999999/
END:VEVENT
END:VCALENDAR
like image 931
d3pd Avatar asked Sep 12 '16 17:09

d3pd


1 Answers

You will need to add an RRULE property to the event. For a repeating Monday event for 2016, you will need to have lines like this in your event:

DTSTART:20160104T130000Z

DTEND:20160104T140000Z

RRULE:FREQ=WEEKLY;UNTIL=20170101T000000Z

You can find the details about the RRULE syntax here: http://icalendar.org/iCalendar-RFC-5545/3-8-5-3-recurrence-rule.html

You may also find it useful to validate your icalendar feed during testing to ensure Google Calendar won't have an issue with it. Here is a useful validation tool: http://icalendar.org/validator.html

Disclaimer: I think the icalendar validator tool is the best on the internet, but I also wrote it :-)

like image 138
zcontent Avatar answered Sep 18 '22 19:09

zcontent