Created
August 17, 2018 18:47
-
-
Save jgonera/8cd883b82c6be48da12acdb3a238db70 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function googleCalendarHoliday() { | |
var fromDate = new Date('2017-12-19T00:00:00-08:00'); | |
var toDate = new Date('2018-01-01T23:30:00-08:00'); | |
var calendarId = "your@gmail"; | |
//Logger.log(CalendarApp.getAllCalendars().map(function(c) { return c.getId() })); | |
var calendar = CalendarApp.getCalendarById(calendarId); | |
var events = calendar.getEvents(fromDate, toDate); | |
Logger.log('Events: ' + events.length); | |
for (var i = 0; i < events.length; i++) { | |
var ev = events[i]; | |
// try/catch for setting status - may get exceptions where events | |
// are on calendar, but user is not a "guest" of the event - these can be ignored | |
try { | |
// !!! | |
ev.removeAllReminders(); | |
ev.setMyStatus(CalendarApp.GuestStatus.NO); | |
// !!! | |
} catch (e) { | |
Logger.log('Error updating event status of ' + ev.getTitle() + ": " + e); | |
} | |
//Logger.log('Item ' + ev.getTitle() + ' found on ' + ev.getStartTime() + ' marked as declined'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment