Skip to content

Instantly share code, notes, and snippets.

wroman / calendarblock
Last active Jul 19, 2021
Auto Block Time on Primary Google Calendar from Events on Secondary Calendar - Instructions:
View calendarblock
function sync() {
var id="XXXXXXXX"; // CHANGE - id of the secondary calendar to pull events from
var secondaryCal=CalendarApp.getCalendarById(id);
var today=new Date();
var enddate=new Date();
enddate.setDate(today.getDate()+30); // how many days in advance to monitor and block off time
var secondaryEvents=secondaryCal.getEvents(today,enddate);