【问题标题】:Get recurrence of CalendarEvent in G-Suite Addon在 G-Suite 插件中获取 CalendarEvent 的重现
【发布时间】:2020-02-07 08:24:00
【问题描述】:

我正在开发一个将事件数据与外部服务同步的 Google 日历插件。获取事件的标题、描述、日期等数据很容易,我什至可以使用event.isRecurringEvent() 检查它是否是重复事件。

我似乎不知道如何获取特定事件的重复规则。这甚至可能吗? https://developers.google.com/apps-script/reference/calendar/calendar-eventhttps://developers.google.com/apps-script/reference/calendar/calendar-event-series 都没有像 getRecurrenceRule() 这样的东西

感谢您的帮助!

【问题讨论】:

标签: google-apps-script google-calendar-recurring-events gsuite-addons


【解决方案1】:

如果我对您的理解正确,您在 Google Apps 脚本中有一个 CalendarEvent,并且您希望重复使用它。

因为,正如您所说,没有像getRecurrenceRule() 这样的方法,您必须激活Advanced Calendar Service 并调用Events: get 以获取有关事件重复发生的信息。如果event 是您的CalendarEvent,您可以通过执行以下操作来检索有关重复的信息:

eventId = event.getId().split("@")[0];
var eventFromAPI = Calendar.Events.get(calId, eventId);
var recurrence = eventFromAPI["recurrence"];
return recurrence;

注意事项:

  • 我正在使用split 删除event.getId() 返回的字符串的@ 之后的字符,因为它附加了@google.com
  • recurrence 是“重复事件的 RRULE、EXRULE、RDATE 和 EXDATE 行列表,如RFC5545 中指定的那样”。尽管这有事件重复发生的信息,但它不是 Apps Script 类RecurrenceRule 的实例。据我所知,没有办法退货。

参考:

希望对你有帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-08-14
    • 1970-01-01
    • 2020-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-27
    相关资源
    最近更新 更多