// Remove all Events between dates given
// if allDay flag set, remove those as well
function delete_TKS_Events(startDate=new Date(),endDate=new Date(),deleteAllDay=true){
var myCalID=SpreadsheetApp.getActiveSpreadsheet().getRangeByName('Selected_Calendar_ID').getValue();
var myCal=CalendarApp.getCalendarById(myCalID);
//logInfo('Deleting Events','Start:'+ startDate +' End:'+endDate+' AllDay:'+deleteAllDay,true);
var allEvents=myCal.getEvents(startDate,endDate);
//logInfo('Delete:','Deleting - '+allEvents.length+' (Includes Day Numbers if appropriate)',true);
for (var e=0;e<allEvents.length;e++){
//Check for event
if (allEvents[e].isAllDayEvent()){
//are we deleting all day events too?
if(deleteAllDay){
allEvents[e].deleteEvent();
}
}else{
//not all day delete it
allEvents[e].deleteEvent();
}
}
//logInfo('Deleted Events','Deleted '+allEvents.length+' events',true);
return true;
}