smallpepperz
smallpepperz

Reputation: 1361

Make a google calendar event the same time everyday without a repeating event

I have a google calendar which I would like to have the same event repeat every day. The event goes from 8 to 9 AM PST and I can't make it a repeating event in google calendar. I have a calendar id for it and I was wondering what the Google Apps Script code should be.

Thanks

Edit: The code that I have so far is this:

function newFunction() {
var cal = CalendarApp.getCalendarById('[email protected]')
//need start and end as date formats

for(i=0; i<30; i++){
cal.createEvent('Test', start,end)
var start = start+1
var end = end+1
}
}

I just need a way to make a date that can be used in creating google calendar events and I can preform addition with

Upvotes: 0

Views: 401

Answers (1)

Andres Duarte
Andres Duarte

Reputation: 3350

You can achieve that by using the createAllDayEventSeries method, for that you'd first need to create an EventOcurrence object with daily rule. Here's an example code I made and it worked successfully creating a recurring event for everyday in March.

function myFunction() {
  var cal = CalendarApp.getCalendarById('[CALENDAR-ID]')
  var startDate = new Date('March 1, 2020 03:00:00 PM EST');
  var endDate = new Date('March 30, 2020')
  var ocurrence = CalendarApp.newRecurrence().addDailyRule().until(endDate);

  var eventSeries = cal.createAllDayEventSeries('No Meetings', startDate, ocurrence, {guests: '[email protected]'});  
  Logger.log('Event Series ID: ' + eventSeries.getId());
}

Upvotes: 1

Related Questions