Calendar Service

  • The Google Apps Script Calendar Service enables interaction with Google Calendars, allowing scripts to create, modify, and delete events and calendars.

  • It offers classes like Calendar, CalendarApp, and CalendarEvent with specific methods for managing various calendar aspects.

  • Recurring events are handled through CalendarEventSeries and RecurrenceRule, which provide extensive options for recurrence patterns and exclusions.

  • The service utilizes enums like Color, EventColor, and Visibility to define event properties.

  • CalendarEvent methods allow detailed control over event details, such as reminders, guests, and visibility settings.

Calendar

This service allows a script to access and modify the user's Google Calendar, including additional calendars that the user is subscribed to.

Classes

NameBrief description
Calendar Represents a calendar that the user owns or is subscribed to.
CalendarApp Allows a script to read and update the user's Google Calendar.
CalendarEvent Represents a single calendar event.
CalendarEventSeries Represents a series of events (a recurring event).
Color An enum representing the named colors available in the Calendar service.
EventColor An enum representing the named event colors available in the Calendar service.
EventGuest Represents a guest of an event.
EventRecurrence Represents the recurrence settings for an event series.
EventTransparency An enum representing the transparency of an event.
EventType An enum representing the type of an event.
GuestStatus An enum representing the statuses a guest can have for an event.
RecurrenceRule Represents a recurrence rule for an event series.
Visibility An enum representing the visibility of an event.

Calendar

Methods

MethodReturn typeBrief description
createAllDayEvent(title, date) CalendarEvent Creates a new all-day event.
createAllDayEvent(title, startDate, endDate) CalendarEvent Creates a new all-day event that can span multiple days.
createAllDayEvent(title, startDate, endDate, options) CalendarEvent Creates a new all-day event that can span multiple days.
createAllDayEvent(title, date, options) CalendarEvent Creates a new all-day event.
createAllDayEventSeries(title, startDate, recurrence) CalendarEventSeries Creates a new all-day event series.
createAllDayEventSeries(title, startDate, recurrence, options) CalendarEventSeries Creates a new all-day event series.
createEvent(title, startTime, endTime) CalendarEvent Creates a new event.
createEvent(title, startTime, endTime, options) CalendarEvent Creates a new event.
createEventFromDescription(description) CalendarEvent Creates an event from a free-form description.
createEventSeries(title, startTime, endTime, recurrence) CalendarEventSeries Creates a new event series.
createEventSeries(title, startTime, endTime, recurrence, options) CalendarEventSeries Creates a new event series.
deleteCalendar() voidDeletes the calendar permanently.
getColor() StringGets the color of the calendar.
getDescription() StringGets the description of the calendar.
getEventById(iCalId) CalendarEvent Gets the event with the given ID.
getEventSeriesById(iCalId) CalendarEventSeries Gets the event series with the given ID.
getEvents(startTime, endTime) CalendarEvent[] Gets all events that occur within a given time range.
getEvents(startTime, endTime, options) CalendarEvent[] Gets all events that occur within a given time range and meet the specified criteria.
getEventsForDay(date) CalendarEvent[] Gets all events that occur on a given day.
getEventsForDay(date, options) CalendarEvent[] Gets all events that occur on a given day and meet specified criteria.
getId() StringGets the ID of the calendar.
getName() StringGets the name of the calendar.
getTimeZone() StringGets the time zone of the calendar.
isHidden() BooleanDetermines whether the calendar is hidden in the user interface.
isMyPrimaryCalendar() BooleanDetermines whether the calendar is the primary calendar for the effective user.
isOwnedByMe() BooleanDetermines whether the calendar is owned by you.
isSelected() BooleanDetermines whether the calendar's events are displayed in the user interface.
setColor(color) Calendar Sets the color of the calendar.
setDescription(description) Calendar Sets the description of a calendar.
setHidden(hidden) Calendar Sets whether the calendar is visible in the user interface.
setName(name) Calendar Sets the name of the calendar.
setSelected(selected) Calendar Sets whether the calendar's events are displayed in the user interface.
setTimeZone(timeZone) Calendar Sets the time zone of the calendar.
unsubscribeFromCalendar() voidUnsubscribes the user from a calendar.

CalendarApp

Properties

PropertyTypeDescription
ColorColor An enum representing the named colors available in the Calendar service.
EventColorEventColor An enum representing the named event colors available in the Calendar service.
EventTransparencyEventTransparency The EventTransparency enumeration.
EventTypeEventType The EventType enumeration.
GuestStatusGuestStatus An enum representing the statuses a guest can have for an event.
MonthMonth An enum representing the months of the year.
VisibilityVisibility An enum representing the visibility of an event.
WeekdayWeekday An enum representing the days of the week.

Methods

MethodReturn typeBrief description
createAllDayEvent(title, date) CalendarEvent Creates a new all-day event.
createAllDayEvent(title, startDate, endDate) CalendarEvent Creates a new all-day event that can span multiple days.
createAllDayEvent(title, startDate, endDate, options) CalendarEvent Creates a new all-day event that can span multiple days.
createAllDayEvent(title, date, options) CalendarEvent Creates a new all-day event.
createAllDayEventSeries(title, startDate, recurrence) CalendarEventSeries Creates a new all-day event series.
createAllDayEventSeries(title, startDate, recurrence, options) CalendarEventSeries Creates a new all-day event series.
createCalendar(name) Calendar Creates a new calendar, owned by the user.
createCalendar(name, options) Calendar Creates a new calendar, owned by the user.
createEvent(title, startTime, endTime) CalendarEvent Creates a new event.
createEvent(title, startTime, endTime, options) CalendarEvent Creates a new event.
createEventFromDescription(description) CalendarEvent Creates an event from a free-form description.
createEventSeries(title, startTime, endTime, recurrence) CalendarEventSeries Creates a new event series.
createEventSeries(title, startTime, endTime, recurrence, options) CalendarEventSeries Creates a new event series.
getAllCalendars() Calendar[] Gets all calendars that the user owns or is subscribed to.
getAllOwnedCalendars() Calendar[] Gets all calendars that the user owns.
getCalendarById(id) Calendar Gets the calendar with the given ID.
getCalendarsByName(name) Calendar[] Gets all calendars with a given name that the user owns or is subscribed to.
getColor() StringGets the color of the calendar.
getDefaultCalendar() Calendar Gets the user's default calendar.
getDescription() StringGets the description of the calendar.
getEventById(iCalId) CalendarEvent Gets the event with the given ID.
getEventSeriesById(iCalId) CalendarEventSeries Gets the event series with the given ID.
getEvents(startTime, endTime) CalendarEvent[] Gets all events that occur within a given time range.
getEvents(startTime, endTime, options) CalendarEvent[] Gets all events that occur within a given time range and meet the specified criteria.
getEventsForDay(date) CalendarEvent[] Gets all events that occur on a given day.
getEventsForDay(date, options) CalendarEvent[] Gets all events that occur on a given day and meet specified criteria.
getId() StringGets the ID of the calendar.
getName() StringGets the name of the calendar.
getOwnedCalendarById(id) Calendar Gets the calendar with the given ID, if the user owns it.
getOwnedCalendarsByName(name) Calendar[] Gets all calendars with a given name that the user owns.
getTimeZone() StringGets the time zone of the calendar.
isHidden() BooleanDetermines whether the calendar is hidden in the user interface.
isMyPrimaryCalendar() BooleanDetermines whether the calendar is the primary calendar for the effective user.
isOwnedByMe() BooleanDetermines whether the calendar is owned by you.
isSelected() BooleanDetermines whether the calendar's events are displayed in the user interface.
newRecurrence() EventRecurrence Creates a new recurrence object, which can be used to create rules for event recurrence.
setColor(color) Calendar Sets the color of the calendar.
setDescription(description) Calendar Sets the description of a calendar.
setHidden(hidden) Calendar Sets whether the calendar is visible in the user interface.
setName(name) Calendar Sets the name of the calendar.
setSelected(selected) Calendar Sets whether the calendar's events are displayed in the user interface.
setTimeZone(timeZone) Calendar Sets the time zone of the calendar.
subscribeToCalendar(id) Calendar Subscribes the user to the calendar with the given ID, if the user is allowed to subscribe.
subscribeToCalendar(id, options) Calendar Subscribes the user to the calendar with the given ID, if the user is allowed to subscribe.

CalendarEvent

Methods

MethodReturn typeBrief description
addEmailReminder(minutesBefore) CalendarEvent Adds a new email reminder to the event.
addGuest(email) CalendarEvent Adds a guest to the event.
addPopupReminder(minutesBefore) CalendarEvent Adds a new pop-up notification to the event.
addSmsReminder(minutesBefore) CalendarEvent Adds a new SMS reminder to the event.
anyoneCanAddSelf() BooleanDetermines whether people can add themselves as guests to a Calendar event.
deleteEvent() voidDeletes a Calendar event.
deleteTag(key) CalendarEvent Deletes a key/value tag from the event.
getAllDayEndDate() DateGets the date on which this all-day calendar event ends.
getAllDayStartDate() DateGets the date on which this all-day calendar event begins.
getAllTagKeys() String[]Gets all keys for tags that have been set on the event.
getColor() StringReturns the color of the calendar event.
getCreators() String[]Gets the creators of an event.
getDateCreated() DateGets the date the event was created.
getDescription() StringGets the description of the event.
getEmailReminders() Integer[]Gets the minute values for all email reminders for the event.
getEndTime() DateGets the date and time at which this calendar event ends.
getEventSeries() CalendarEventSeries Gets the series of recurring events that this event belongs to.
getEventType() EventType Gets the EventType of this event.
getGuestByEmail(email) EventGuest Gets a guest by email address.
getGuestList() EventGuest[] Gets the guests for the event, not including the event owner.
getGuestList(includeOwner) EventGuest[] Gets the guests for the event, potentially including the event owners.
getId() StringGets the unique iCalUID of the event.
getLastUpdated() DateGets the date the event was last updated.
getLocation() StringGets the location of the event.
getMyStatus() GuestStatus Gets the event status (such as attending or invited) of the effective user.
getOriginalCalendarId() StringGet the ID of the calendar where this event was originally created.
getPopupReminders() Integer[]Gets the minute values for all pop-up reminders for the event.
getSmsReminders() Integer[]Gets the minute values for all SMS reminders for the event.
getStartTime() DateGets the date and time at which this calendar event begins.
getTag(key) StringGets a tag value of the event.
getTitle() StringGets the title of the event.
getTransparency() EventTransparency Gets the transparency of the event.
getVisibility() Visibility Gets the visibility of the event.
guestsCanInviteOthers() BooleanDetermines whether guests can invite other guests.
guestsCanModify() BooleanDetermines whether guests can modify the event.
guestsCanSeeGuests() BooleanDetermines whether guests can see other guests.
isAllDayEvent() BooleanDetermines whether this is an all-day event.
isOwnedByMe() BooleanDetermines whether you're the owner of the event.
isRecurringEvent() BooleanDetermines whether the event is part of an event series.
removeAllReminders() CalendarEvent Removes all reminders from the event.
removeGuest(email) CalendarEvent Removes a guest from the event.
resetRemindersToDefault() CalendarEvent Resets the reminders using the calendar's default settings.
setAllDayDate(date) CalendarEvent Sets the date of the event.
setAllDayDates(startDate, endDate) CalendarEvent Sets the dates of the event.
setAnyoneCanAddSelf(anyoneCanAddSelf) CalendarEvent Sets whether non-guests can add themselves to the event.
setColor(color) CalendarEvent Sets the color of the calendar event.
setDescription(description) CalendarEvent Sets the description of the event.
setGuestsCanInviteOthers(guestsCanInviteOthers) CalendarEvent Sets whether guests can invite other guests.
setGuestsCanModify(guestsCanModify) CalendarEvent Sets whether guests can modify the event.
setGuestsCanSeeGuests(guestsCanSeeGuests) CalendarEvent Sets whether guests can see other guests.
setLocation(location) CalendarEvent Sets the location of the event.
setMyStatus(status) CalendarEvent Sets the event status (such as attending or invited) of the effective user.
setTag(key, value) CalendarEvent Sets a key/value tag on the event, for storing custom metadata.
setTime(startTime, endTime) CalendarEvent Sets the dates and times for the start and end of the event.
setTitle(title) CalendarEvent Sets the title of the event.
setTransparency(transparency) CalendarEvent Sets the transparency of the event.
setVisibility(visibility) CalendarEvent Sets the visibility of the event.

CalendarEventSeries

Methods

MethodReturn typeBrief description
addEmailReminder(minutesBefore) CalendarEventSeries Adds a new email reminder to the event.
addGuest(email) CalendarEventSeries Adds a guest to the event.
addPopupReminder(minutesBefore) CalendarEventSeries Adds a new pop-up notification to the event.
addSmsReminder(minutesBefore) CalendarEventSeries Adds a new SMS reminder to the event.
anyoneCanAddSelf() BooleanDetermines whether people can add themselves as guests to a Calendar event.
deleteEventSeries() voidDeletes the event series.
deleteTag(key) CalendarEventSeries Deletes a key/value tag from the event.
getAllTagKeys() String[]Gets all keys for tags that have been set on the event.
getColor() StringReturns the color of the calendar event.
getCreators() String[]Gets the creators of an event.
getDateCreated() DateGets the date the event was created.
getDescription() StringGets the description of the event.
getEmailReminders() Integer[]Gets the minute values for all email reminders for the event.
getEventType() EventType Gets the EventType of this event.
getGuestByEmail(email) EventGuest Gets a guest by email address.
getGuestList() EventGuest[] Gets the guests for the event, not including the event owner.
getGuestList(includeOwner) EventGuest[] Gets the guests for the event, potentially including the event owners.
getId() StringGets the unique iCalUID of the event.
getLastUpdated() DateGets the date the event was last updated.
getLocation() StringGets the location of the event.
getMyStatus() GuestStatus Gets the event status (such as attending or invited) of the effective user.
getOriginalCalendarId() StringGet the ID of the calendar where this event was originally created.
getPopupReminders() Integer[]Gets the minute values for all pop-up reminders for the event.
getSmsReminders() Integer[]Gets the minute values for all SMS reminders for the event.
getTag(key) StringGets a tag value of the event.
getTitle() StringGets the title of the event.
getTransparency() EventTransparency Gets the transparency of the event.
getVisibility() Visibility Gets the visibility of the event.
guestsCanInviteOthers() BooleanDetermines whether guests can invite other guests.
guestsCanModify() BooleanDetermines whether guests can modify the event.
guestsCanSeeGuests() BooleanDetermines whether guests can see other guests.
isOwnedByMe() BooleanDetermines whether you're the owner of the event.
removeAllReminders() CalendarEventSeries Removes all reminders from the event.
removeGuest(email) CalendarEventSeries Removes a guest from the event.
resetRemindersToDefault() CalendarEventSeries Resets the reminders using the calendar's default settings.
setAnyoneCanAddSelf(anyoneCanAddSelf) CalendarEventSeries Sets whether non-guests can add themselves to the event.
setColor(color) CalendarEventSeries Sets the color of the calendar event.
setDescription(description) CalendarEventSeries Sets the description of the event.
setGuestsCanInviteOthers(guestsCanInviteOthers) CalendarEventSeries Sets whether guests can invite other guests.
setGuestsCanModify(guestsCanModify) CalendarEventSeries Sets whether guests can modify the event.
setGuestsCanSeeGuests(guestsCanSeeGuests) CalendarEventSeries Sets whether guests can see other guests.
setLocation(location) CalendarEventSeries Sets the location of the event.
setMyStatus(status) CalendarEventSeries Sets the event status (such as attending or invited) of the effective user.
setRecurrence(recurrence, startDate) CalendarEventSeries Sets the recurrence rules for an all-day event series.
setRecurrence(recurrence, startTime, endTime) CalendarEventSeries Sets the recurrence rules for this event series.
setTag(key, value) CalendarEventSeries Sets a key/value tag on the event, for storing custom metadata.
setTitle(title) CalendarEventSeries Sets the title of the event.
setTransparency(transparency) CalendarEventSeries Sets the transparency of the event.
setVisibility(visibility) CalendarEventSeries Sets the visibility of the event.

Color

Properties

PropertyTypeDescription
BLUEEnum Blue (#2952A3).
BROWNEnum Brown (#8D6F47).
CHARCOALEnum Charcoal (#4E5D6C).
CHESTNUTEnum Chestnut (#865A5A).
GRAYEnum Gray (#5A6986).
GREENEnum Green (#0D7813).
INDIGOEnum Indigo (#5229A3).
LIMEEnum Lime (#528800).
MUSTARDEnum Mustard (#88880E).
OLIVEEnum Olive (#6E6E41).
ORANGEEnum Orange (#BE6D00).
PINKEnum Pink (#B1365F).
PLUMEnum Plum (#705770).
PURPLEEnum Purple (#7A367A).
REDEnum Red (#A32929).
RED_ORANGEEnum Red-Orange (#B1440E).
SEA_BLUEEnum Sea Blue (#29527A).
SLATEEnum Slate (#4A716C).
TEALEnum Teal (#28754E).
TURQOISEEnum Turquoise (#1B887A).
YELLOWEnum Yellow (#AB8B00).

EventColor

Properties

PropertyTypeDescription
PALE_BLUEEnum Pale Blue ("1"), referred to as "Peacock" in th Calendar UI.
PALE_GREENEnum Pale Green ("2"), referred to as "Sage" in th Calendar UI.
MAUVEEnum Mauve ("3"),, referred to as "Grape" in th Calendar UI.
PALE_REDEnum Pale Red ("4"), referred to as "Flamingo" in th Calendar UI.
YELLOWEnum Yellow ("5"), referred to as "Banana" in th Calendar UI.
ORANGEEnum Orange ("6"), referred to as "Tangerine" in th Calendar UI.
CYANEnum Cyan ("7"), referred to as "Lavender" in th Calendar UI.
GRAYEnum Gray ("8"), referred to as "Graphite" in th Calendar UI.
BLUEEnum Blue ("9"), referred to as "Blueberry" in th Calendar UI.
GREENEnum Green ("10"), referred to as "Basil" in th Calendar UI.
REDEnum Red ("11"), referred to as "Tomato" in th Calendar UI.

EventGuest

Methods

MethodReturn typeBrief description
getAdditionalGuests() IntegerGets the number of additional people that this guest has said are attending.
getEmail() StringGets the email address of the guest.
getGuestStatus() GuestStatus Gets the status of the guest for the event.
getName() StringGets the name of the guest.

EventRecurrence

Methods

MethodReturn typeBrief description
addDailyExclusion() RecurrenceRule Adds a rule that excludes occurrences on a daily basis.
addDailyRule() RecurrenceRule Adds a rule that causes the event to recur on a daily basis.
addDate(date) EventRecurrence Adds a rule that causes the event to recur on a specific date.
addDateExclusion(date) EventRecurrence Adds a rule that excludes an occurrence for a specific date.
addMonthlyExclusion() RecurrenceRule Adds a rule that excludes occurrences on a monthly basis.
addMonthlyRule() RecurrenceRule Adds a rule that causes the event to recur on a monthly basis.
addWeeklyExclusion() RecurrenceRule Adds a rule that excludes occurrences on a weekly basis.
addWeeklyRule() RecurrenceRule Adds a rule that causes the event to recur on a weekly basis.
addYearlyExclusion() RecurrenceRule Adds a rule that excludes occurrences on a yearly basis.
addYearlyRule() RecurrenceRule Adds a rule that causes the event to recur on a yearly basis.
setTimeZone(timeZone) EventRecurrence Sets the time zone for this recurrence.

EventTransparency

Properties

PropertyTypeDescription
OPAQUEEnumThe event does block time on the calendar.
TRANSPARENTEnumThe event does not block time on the calendar.

EventType

Properties

PropertyTypeDescription
DEFAULTEnumThe event is a regular event.
BIRTHDAYEnumThe event is a special all-day event with an annual recurrence.
FOCUS_TIMEEnumThe event is a focus-time event.
FROM_GMAILEnumThe event is an event from Gmail.
OUT_OF_OFFICEEnumThe event is an out-of-office event.
WORKING_LOCATIONEnumThe event is a working location event.

GuestStatus

Properties

PropertyTypeDescription
INVITEDEnumThe guest has been invited, but has not indicated whether they are attending.
MAYBEEnumThe guest has indicated they might attend.
NOEnumThe guest has indicated they are not attending.
OWNEREnumThe guest is the owner of the event.
YESEnumThe guest has indicated they are attending.

RecurrenceRule

Methods

MethodReturn typeBrief description
addDailyExclusion() RecurrenceRule Adds a rule that excludes occurrences on a daily basis.
addDailyRule() RecurrenceRule Adds a rule that causes the event to recur on a daily basis.
addDate(date) EventRecurrence Adds a rule that causes the event to recur on a specific date.
addDateExclusion(date) EventRecurrence Adds a rule that excludes an occurrence for a specific date.
addMonthlyExclusion() RecurrenceRule Adds a rule that excludes occurrences on a monthly basis.
addMonthlyRule() RecurrenceRule Adds a rule that causes the event to recur on a monthly basis.
addWeeklyExclusion() RecurrenceRule Adds a rule that excludes occurrences on a weekly basis.
addWeeklyRule() RecurrenceRule Adds a rule that causes the event to recur on a weekly basis.
addYearlyExclusion() RecurrenceRule Adds a rule that excludes occurrences on a yearly basis.
addYearlyRule() RecurrenceRule Adds a rule that causes the event to recur on a yearly basis.
interval(interval) RecurrenceRule Configures the rule to only apply at this interval of the rule's time unit.
onlyInMonth(month) RecurrenceRule Configures the rule to only apply to a specific month.
onlyInMonths(months) RecurrenceRule Configures the rule to only apply to specific months.
onlyOnMonthDay(day) RecurrenceRule Configures the rule to only apply to a specific day of the month.
onlyOnMonthDays(days) RecurrenceRule Configures the rule to only apply to specific days of the month.
onlyOnWeek(week) RecurrenceRule Configures the rule to only apply to a specific week of the year.
onlyOnWeekday(day) RecurrenceRule Configures the rule to only apply to a specific day of the week.
onlyOnWeekdays(days) RecurrenceRule Configures the rule to only apply to specific days of the week.
onlyOnWeeks(weeks) RecurrenceRule Configures the rule to only apply to specific weeks of the year.
onlyOnYearDay(day) RecurrenceRule Configures the rule to only apply to a specific day of the year.
onlyOnYearDays(days) RecurrenceRule Configures the rule to only apply to specific days of the year.
setTimeZone(timeZone) EventRecurrence Sets the time zone for this recurrence.
times(times) RecurrenceRule Configures the rule to end after a given number of occurrences.
until(endDate) RecurrenceRule Configures the rule to end on a given date (inclusive).
weekStartsOn(day) RecurrenceRule Configures which day a week starts on, for the purposes of applying the rule.

Visibility

Properties

PropertyTypeDescription
CONFIDENTIALEnumThe event is private.
DEFAULTEnumUses the default visibility for events on the calendar.
PRIVATEEnumThe event is private and only event attendees may view event details.
PUBLICEnumThe event is public and event details are visible to all readers of the calendar.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024年12月09日 UTC.