首页 > 解决方案 > 如何为 Google Calendar API 制定自定义重复规则?

问题描述

我正在开发一个项目,我必须在 Google 日历中为最终用户安排一些重复性事件。我一直在使用日历的 Python API,到目前为止,根据 RFC 5545 标准使用最常见的循环规则我没有遇到任何问题。

但是,在没有模式的情况下安排重复事件会很有帮助。我的意思是,我不想告诉谷歌在周五每周安排 3 次,而是想指定此类事件的日期,并将它们全部注册在同一个事件 ID 下。

有谁知道这是否可能?任何评论将不胜感激!

标签: pythonapipython-requestsgoogle-calendar-apirfc5545

解决方案


这是可能的,但不是很容易。您提到的标准在此处实际描述了这一点:链接到标准页面 120

  The recurrence dates, if specified, are used in computing the
  recurrence set.  The recurrence set is the complete set of
  recurrence instances for a calendar component.  The recurrence set
  is generated by considering the initial "DTSTART" property along
  with the "RRULE", "RDATE", and "EXDATE" properties contained
  within the recurring component.  The "DTSTART" property defines
  the first instance in the recurrence set.  The "DTSTART" property
  value SHOULD match the pattern of the recurrence rule, if
  specified.  The recurrence set generated with a "DTSTART" property
  value that doesn't match the pattern of the rule is undefined.
  The final recurrence set is generated by gathering all of the
  start DATE-TIME values generated by any of the specified "RRULE"
  and "RDATE" properties, and then excluding any start DATE-TIME
  values specified by "EXDATE" properties.  This implies that start
  DATE-TIME values specified by "EXDATE" properties take precedence
  over those specified by inclusion properties (i.e., "RDATE" and
  "RRULE").  Where duplicate instances are generated by the "RRULE"
  and "RDATE" properties, only one recurrence is considered.
  Duplicate instances are ignored.

这意味着您可以有一个开始日期 ( DTSTART) 和一个重复规则 ( RRULE)。通过使用EXDATE,您可以创建一个 RRULE 表示“从 STARTDATE 到 ENDDATE 的每一天,除了 [您不想要的所有时间列表]”。这仅适用于每天,您不能按照标准每小时开会。


推荐阅读