iCalendar 排除日期范围
iCalendar exclude date range
我正在研究学校时间表系统,目前正在开发一个 PHP 脚本,该脚本允许以 iCalendar (.ics) 格式导出数据。导出数据的目标用例是将其导入 Google 日历。
由于我们学校的学期之间有假期(由开始和结束日期指定),从 iCalendar 重复规则中排除假期的最佳方法是什么(RRULE
)?。请记住,一次导出可以有多个不同的时间表。
我确实尝试将 EXDATE;VALUE=DATE:YYYYMMDD,YYYYMMDD,YYYYMMDD...
用于所有假期,但 Google 日历没有排除日期,可能是因为日程表也有附加时间,因此它们不匹配。
我还将为其中一个事件提供 iCalendar 格式的数据,假期一一排除(没有工作的那个)
BEGIN:VCALENDAR
PRODID:-//Gregor Eesmaa/NONSGML Poska timetables//ET
VERSION:2.0
METHOD:PUBLISH
BEGIN:VEVENT
UID:schedule-1442@jpg.tartu.ee
SUMMARY:French
DESCRIPTION:
LOCATION:Room 210
DTSTART:20151215T123000Z
DTEND:20151215T134500Z
RRULE:FREQ=WEEKLY;UNTIL=20160211;INTERVAL=1;BYDAY=TU
EXDATE;VALUE=DATE:20151223,20151224,20151225,20151226,20151227,20151228,20151229,20151230,20151231,20160101,20160102,20160103,20160104,20160105,20160106,20160107,20160108,20160109,20160110,20160319,20160320,20160321,20160322,20160323,20160324,20160325,20160326,20160327,20160415,20160416,20160417,20160418,20160607,20160608,20160609,20160610,20160611,20160612,20160613,20160614,20160615,20160616,20160617,20160618,20160619,20160620,20160621,20160622,20160623,20160624,20160625,20160626,20160627,20160628,20160629,20160630,20160701,20160702,20160703,20160704,20160705,20160706,20160707,20160708,20160709,20160710,20160711,20160712,20160713,20160714,20160715,20160716,20160717,20160718,20160719,20160720,20160721,20160722,20160723,20160724,20160725,20160726,20160727,20160728,20160729,20160730,20160731,20160801,20160802,20160803,20160804,20160805,20160806,20160807,20160808,20160809,20160810,20160811,20160812,20160813,20160814,20160815,20160816,20160817,20160818,20160819,20160820,20160821,20160822,20160823,20160824,20160825,20160826,20160827,20160828,20160829,20160830,20160831
LAST-MODIFIED:20160102T123758Z
DTSTAMP:20160107T232137Z
END:VEVENT
END:VCALENDAR
基于此其他 SO issue, it seems you're not setting any excluded date in EXDATE
. EXDATE
can be set to DATE
, based on the RFC 5545 规范。
根据其他问题的回答,你的EXDATE
应该是
EXDATE:20151223,20151224,20151225,20151226,20151227,20151228,20151229,20151230,20151231,20160101,20160102,20160103,20160104,20160105,20160106,20160107,20160108,20160109,20160110,20160319,20160320,20160321,20160322,20160323,20160324,20160325,20160326,20160327,20160415,20160416,20160417,20160418,20160607,20160608,20160609,20160610,20160611,20160612,20160613,20160614,20160615,20160616,20160617,20160618,20160619,20160620,20160621,20160622,20160623,20160624,20160625,20160626,20160627,20160628,20160629,20160630,20160701,20160702,20160703,20160704,20160705,20160706,20160707,20160708,20160709,20160710,20160711,20160712,20160713,20160714,20160715,20160716,20160717,20160718,20160719,20160720,20160721,20160722,20160723,20160724,20160725,20160726,20160727,20160728,20160729,20160730,20160731,20160801,20160802,20160803,20160804,20160805,20160806,20160807,20160808,20160809,20160810,20160811,20160812,20160813,20160814,20160815,20160816,20160817,20160818,20160819,20160820,20160821,20160822,20160823,20160824,20160825,20160826,20160827,20160828,20160829,20160830,20160831
希望对您有所帮助!
如果 DTSTART 是一个 date-time 值,那么 EXDATE 也必须是 date-times。我建议您将 T123000Z 附加到每个 EXDATE,使它们实际指向有效的实例启动。然后他们将被正确排除。
我发布了这个问题来寻找排除整个范围的解决方案。经过仔细考虑,我决定通过仅排除事件实际发生的 date-times 来正确地执行此操作。这将导出的文件大小减少了三倍。
我还按照使用 RRULE
的建议添加了时区信息。现在法语课活动看起来像这样:
BEGIN:VEVENT
UID:schedule-1442@jpg.tartu.ee
SUMMARY:French
DESCRIPTION:
LOCATION:Room 210
DTSTART;TZID=Europe/Tallinn:20151215T143000
DTEND;TZID=Europe/Tallinn:20151215T154500
RRULE:FREQ=WEEKLY;UNTIL=20160211;INTERVAL=1;BYDAY=TU
EXDATE;TZID=Europe/Tallinn:20151229T143000,20160105T143000
CREATED:20160102T123758Z
LAST-MODIFIED:20160102T123758Z
DTSTAMP:20160108T115122Z
END:VEVENT
我正在研究学校时间表系统,目前正在开发一个 PHP 脚本,该脚本允许以 iCalendar (.ics) 格式导出数据。导出数据的目标用例是将其导入 Google 日历。
由于我们学校的学期之间有假期(由开始和结束日期指定),从 iCalendar 重复规则中排除假期的最佳方法是什么(RRULE
)?。请记住,一次导出可以有多个不同的时间表。
我确实尝试将 EXDATE;VALUE=DATE:YYYYMMDD,YYYYMMDD,YYYYMMDD...
用于所有假期,但 Google 日历没有排除日期,可能是因为日程表也有附加时间,因此它们不匹配。
我还将为其中一个事件提供 iCalendar 格式的数据,假期一一排除(没有工作的那个)
BEGIN:VCALENDAR
PRODID:-//Gregor Eesmaa/NONSGML Poska timetables//ET
VERSION:2.0
METHOD:PUBLISH
BEGIN:VEVENT
UID:schedule-1442@jpg.tartu.ee
SUMMARY:French
DESCRIPTION:
LOCATION:Room 210
DTSTART:20151215T123000Z
DTEND:20151215T134500Z
RRULE:FREQ=WEEKLY;UNTIL=20160211;INTERVAL=1;BYDAY=TU
EXDATE;VALUE=DATE:20151223,20151224,20151225,20151226,20151227,20151228,20151229,20151230,20151231,20160101,20160102,20160103,20160104,20160105,20160106,20160107,20160108,20160109,20160110,20160319,20160320,20160321,20160322,20160323,20160324,20160325,20160326,20160327,20160415,20160416,20160417,20160418,20160607,20160608,20160609,20160610,20160611,20160612,20160613,20160614,20160615,20160616,20160617,20160618,20160619,20160620,20160621,20160622,20160623,20160624,20160625,20160626,20160627,20160628,20160629,20160630,20160701,20160702,20160703,20160704,20160705,20160706,20160707,20160708,20160709,20160710,20160711,20160712,20160713,20160714,20160715,20160716,20160717,20160718,20160719,20160720,20160721,20160722,20160723,20160724,20160725,20160726,20160727,20160728,20160729,20160730,20160731,20160801,20160802,20160803,20160804,20160805,20160806,20160807,20160808,20160809,20160810,20160811,20160812,20160813,20160814,20160815,20160816,20160817,20160818,20160819,20160820,20160821,20160822,20160823,20160824,20160825,20160826,20160827,20160828,20160829,20160830,20160831
LAST-MODIFIED:20160102T123758Z
DTSTAMP:20160107T232137Z
END:VEVENT
END:VCALENDAR
基于此其他 SO issue, it seems you're not setting any excluded date in EXDATE
. EXDATE
can be set to DATE
, based on the RFC 5545 规范。
根据其他问题的回答,你的EXDATE
应该是
EXDATE:20151223,20151224,20151225,20151226,20151227,20151228,20151229,20151230,20151231,20160101,20160102,20160103,20160104,20160105,20160106,20160107,20160108,20160109,20160110,20160319,20160320,20160321,20160322,20160323,20160324,20160325,20160326,20160327,20160415,20160416,20160417,20160418,20160607,20160608,20160609,20160610,20160611,20160612,20160613,20160614,20160615,20160616,20160617,20160618,20160619,20160620,20160621,20160622,20160623,20160624,20160625,20160626,20160627,20160628,20160629,20160630,20160701,20160702,20160703,20160704,20160705,20160706,20160707,20160708,20160709,20160710,20160711,20160712,20160713,20160714,20160715,20160716,20160717,20160718,20160719,20160720,20160721,20160722,20160723,20160724,20160725,20160726,20160727,20160728,20160729,20160730,20160731,20160801,20160802,20160803,20160804,20160805,20160806,20160807,20160808,20160809,20160810,20160811,20160812,20160813,20160814,20160815,20160816,20160817,20160818,20160819,20160820,20160821,20160822,20160823,20160824,20160825,20160826,20160827,20160828,20160829,20160830,20160831
希望对您有所帮助!
如果 DTSTART 是一个 date-time 值,那么 EXDATE 也必须是 date-times。我建议您将 T123000Z 附加到每个 EXDATE,使它们实际指向有效的实例启动。然后他们将被正确排除。
我发布了这个问题来寻找排除整个范围的解决方案。经过仔细考虑,我决定通过仅排除事件实际发生的 date-times 来正确地执行此操作。这将导出的文件大小减少了三倍。
我还按照使用 RRULE
的建议添加了时区信息。现在法语课活动看起来像这样:
BEGIN:VEVENT
UID:schedule-1442@jpg.tartu.ee
SUMMARY:French
DESCRIPTION:
LOCATION:Room 210
DTSTART;TZID=Europe/Tallinn:20151215T143000
DTEND;TZID=Europe/Tallinn:20151215T154500
RRULE:FREQ=WEEKLY;UNTIL=20160211;INTERVAL=1;BYDAY=TU
EXDATE;TZID=Europe/Tallinn:20151229T143000,20160105T143000
CREATED:20160102T123758Z
LAST-MODIFIED:20160102T123758Z
DTSTAMP:20160108T115122Z
END:VEVENT