Skip to content

Instantly share code, notes, and snippets.

@marcusmoore
Forked from mogsdad/GCalUtils.md
Created September 23, 2015 17:19
Show Gist options
  • Select an option

  • Save marcusmoore/5ad1d9129495d359135e to your computer and use it in GitHub Desktop.

Select an option

Save marcusmoore/5ad1d9129495d359135e to your computer and use it in GitHub Desktop.
Collection of Google Calendar related utility functions for Google Apps Script.
/** @module GCalUtils */
/**
* Gets all events that occur within a given time range,
* and that include the specified guest email in the
* guest list.
*
* @param {Calendar} calen Calendar to search
* @param {Date} start the start of the time range
* @param {Date} end the end of the time range, non-inclusive
* @param {String} guestEmail Guest email address to search for
*
* @return {CalendarEvent[]} the matching events
*
* @see {@link https://developers.google.com/apps-script/reference/calendar/calendar-app?hl=en#getEvents(Date,Date)|CalendarApp.getEvents(Date,Date)}
* @see {@link https://developers.google.com/apps-script/reference/calendar/calendar-event|Class CalendarEvent}
*/
function getEventsWithGuest(calen,start,end,guestEmail) {
var events = calen.getEvents(start, end);
var i = events.length;
while (i--) {
if (!events[i].getGuestByEmail(guestEmail)) {
events.splice(i, 1);
}
}
return events;
}

getEventsWithGuest

Gets all events that occur within a given time range, and that include the specified guest email in the guest list.

###Parameters:###

Name Type Description
calen Calendar Calendar to search
start Date the start of the time range
end Date the end of the time range, non-inclusive
guestEmail String Guest email address to search for
See:

###Returns:### the matching events

Type
CalendarEvent[]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment