Fuh*_*tor 5 google-calendar-api google-apps-script google-calendar-recurring-events
使用Google Apps脚本,我创建了一个具有复杂定期事件的日历.但是,我无法将该事件复制到另一个日历作为重复发生的事件.注意:无法通过Web界面生成或编辑重复规则.
举一个真实的例子,假设用户想要从这个公开共享的Google日历中复制定期事件.该活动是我大学周四课程的课程安排的模板活动.
以下是阻止用户将定期事件复制到用户有权访问的另一个日历的两个困难:
编辑这里是一个屏幕截图,显示事件在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
| 归档时间: |
|
| 查看次数: |
1264 次 |
| 最近记录: |