复制以编程方式创建的定期事件?

Fuh*_*tor 5 google-calendar-api google-apps-script google-calendar-recurring-events

使用Google Apps脚本,我创建了一个具有复杂定期事件的日历.但是,我无法将该事件复制到另一个日历作为重复发生的事件.注意:无法通过Web界面生成或编辑重复规则.

举一个真实的例子,假设用户想要从这个公开共享的Google日历中复制定期事件.该活动是我大学周四课程的课程安排的模板活动.

以下是阻止用户将定期事件复制到用户有权访问的另一个日历的两个困难:

  • 单击该事件的实例并说"复制到我的日历"仅复制该单个事件,即使该事件被定义为重复.这不是一个好的解决方案,因为用户必须执行此操作超过10次才能获得一个学期的所有事件.
  • 单击事件的实例,然后单击"更多详细信息",然后尝试"更多操作"菜单下的"复制到xxxx"(其中xxxx是用户拥有的日历)似乎正常工作.但是,单击"保存"时会出现错误:"发生错误.请稍后再试."

编辑这里是一个屏幕截图,显示事件在Google日历中的样子(点击事件,"更多详情").

屏幕截图所创建事件的详细信息

请注意,这个重复发生的事件是从学期开始到结束的每个星期一,有几个例外.没有假期(例如,星期一2013-02-25),但也包括星期三2013-02-27,在哪一天,课程将被视为星期一(根据大学课程安排).

我再说一遍:重复活动在Google日历中看起来很不错,但不能将它们全部复制到另一个日历中.

创建日历的GAS函数(不是所有代码都在这里):

function createCalendar(calendarName, courseCode, weekday, times, room, isLab) {

  Logger.log("Last day: " + LAST_TRIMESTER_DATE);
  // hack the last day so that it's not midnight but rather just before the next day, i.e., 23:59:59
  var adjustedLastDay = LAST_TRIMESTER_DATE;
  adjustedLastDay.setTime(adjustedLastDay.getTime() + (23*60*60*1000) + (59*60*1000) + (59*1000));
  Logger.log("Adjusted last day: " + adjustedLastDay);

  var eventRecurrence = CalendarApp.newRecurrence();
  eventRecurrence.addDailyRule().until(adjustedLastDay).interval(1).onlyOnWeekday(weekday);

  // get the day of the week of the first day
  var weekdayOfFirstDay = Utilities.formatDate(FIRST_TRIMESTER_DATE, LONG_TIME_ZONE, "EEEE").toUpperCase();

  // if this calendar is for a lab, exclude the first week of days
  if (isLab) {
    eventRecurrence.addDailyExclusion().times(1);
  } else {
    // it's a course, so exclude the first day if it's not the course day
    //  -- this is kind of a bug, since the "first day" of the event will always try to be created, even if it's not "onlyOnWeekday" specified
    if (weekdayOfFirstDay != weekday.toString()) {
      eventRecurrence.addDailyExclusion().times(1);
//    eventRecurrence.addDateExclusion(FIRST_TRIMESTER_DATE);
    }
  }

  // Exclude all holidays
  for (var i =  0; i 

Eri*_*eda 3

这似乎是 Google 日历中的一个错误,因为它无法复制复杂的重复规则。您可以使用 Google 日历界面中齿轮图标下的“发送反馈”链接向团队报告。