Using Google Apps Script, I created a calendar that has a complex recurring event. However, I'm not able to copy that event to another calendar as a recurring event. Note: the recurring rule can't be generated or edited via the web interface.
For a real example, let's say a user wants to copy the recurring event from this publicly shared Google calendar. The event is a kind of template event for a course schedule of a Thursday course at my university.
Here are two difficulties preventing the user from copying the recurring event into another calendar the user has access to:
EDIT here's a screen shot of what the Event looks like in Google Calendar (click on event, "more details").
Note that this recurring event is every Monday from the start of the semester to the end, with several exceptions. No holidays (e.g., Mon 2013-02-25), but also including Wed 2013-02-27, on which day the courses will be given as if it were a Monday (according to the university course schedule).
I repeat: the recurring events look fine in Google Calendar, but they can't be copied in there entirety to another calendar.
The GAS function that creates the calendars (not all the code is here):
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
This appears to be a bug in Google Calendar, in that it has trouble copying complex recurrence rules. You can report it to the team by using the "Send feedback" link under the gear icon in the Google Calendar interface.
The other option would be to try and export the ICA and have the user import it. You might be even able to do both with some sort of link button. Here is an example of how to obtain the ica file for a google event;
http://google.com/calendar/ical/[CALENDARID]/public[or private depending]/full/[eventID].ics
This should give the code to the user and they can manually import it into their calendars. You can generate the url and send in an email to all students who sign up for the named course.
T
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With