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

自古美人都是妖i 提交于 2019-12-01 03:23:21

问题


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:indico-event-563636@sern.ch
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:indico-event-565483@sern.ch
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:indico-event-565483@sern.ch
DESCRIPTION:https://indico.sern.ch/event/999999/
LOCATION:42-3-002 (SERN)
URL:https://indico.sern.ch/event/999999/
END:VEVENT
END:VCALENDAR

回答1:


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 :-)



来源:https://stackoverflow.com/questions/39455376/how-can-an-ics-file-be-written-for-a-recurring-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!