如何为重复事件写入ICS文件? [英] How can an ICS file be written for a recurring event?

查看:120
本文介绍了如何为重复事件写入ICS文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个描述周期性事件的ICS文件,该事件发生在2016年全年的每个星期一的世界标准时间13:00至14:00。该ICS文件应可由Google日历导入。我发现很难在网上找到和了解有关如何构造此类文件的详细信息。我目前所拥有的是一种创建包含单个事件列表的文件的方法,但是我想在文件中定义一个事件规则。我现在有类似以下内容的东西:

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






编辑:解决方案(由 zcontent 提供),我编写了以下ICS文件,该文件似乎可以成功运行:


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


推荐答案

您将需要向事件添加RRULE属性。对于2016年重复的星期一活动,您需要在活动中添加以下行:

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

DTSTART:20160104T130000Z

DTEND:20160104T140000Z

DTEND:20160104T140000Z

RRULE:FREQ = WEEKLY; UNTIL = 20170101T000000Z

RRULE:FREQ=WEEKLY;UNTIL=20170101T000000Z

您可以找到详细信息有关RRULE语法的信息,请参见:
http ://icalendar.org/iCalendar-RFC-5545/3-8-5-3-recurrence-rule.html

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

您可能还会找到它在测试过程中用于验证您的icalendar feed很有用,以确保Google日历不会出现问题。这是一个有用的验证工具:
http://icalendar.org/validator.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

免责声明:我认为icalendar验证程序工具是Internet上最好的工具,但我也写了它:-)

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

这篇关于如何为重复事件写入ICS文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆