Class CalendarApp

CalendarApp

ユーザーの Google カレンダーの読み取りと更新をスクリプトに許可します。このクラスは、ユーザーのデフォルト カレンダーへの直接アクセスと、ユーザーが所有または登録した追加のカレンダーの取得機能を提供します。

プロパティ

プロパティタイプ説明
ColorColorカレンダー サービスで利用可能な名前付きの色を表す列挙型。
EventColorEventColorカレンダー サービスで利用可能な名前付き予定の色を表す列挙型。
GuestStatusGuestStatusゲストがイベントに対して行えるステータスを表す列挙型。
MonthMonth月を表す列挙型。
VisibilityVisibilityイベントの公開設定を表す列挙型。
WeekdayWeekday曜日を表す列挙型。

Methods

メソッド戻り値の型概要
createAllDayEvent(title, date)CalendarEvent終日の予定を作成します。
createAllDayEvent(title, startDate, endDate)CalendarEvent数日にわたる新しい終日の予定を作成します。
createAllDayEvent(title, startDate, endDate, options)CalendarEvent数日にわたる新しい終日の予定を作成します。
createAllDayEvent(title, date, options)CalendarEvent終日の予定を作成します。
createAllDayEventSeries(title, startDate, recurrence)CalendarEventSeries終日の予定を新規作成します。
createAllDayEventSeries(title, startDate, recurrence, options)CalendarEventSeries終日の予定を新規作成します。
createCalendar(name)Calendarユーザーが所有する新しいカレンダーを作成します。
createCalendar(name, options)Calendarユーザーが所有する新しいカレンダーを作成します。
createEvent(title, startTime, endTime)CalendarEvent新しいイベントを作成します。
createEvent(title, startTime, endTime, options)CalendarEvent新しいイベントを作成します。
createEventFromDescription(description)CalendarEvent自由形式の説明からイベントを作成します。
createEventSeries(title, startTime, endTime, recurrence)CalendarEventSeries新しいイベント シリーズを作成します。
createEventSeries(title, startTime, endTime, recurrence, options)CalendarEventSeries新しいイベント シリーズを作成します。
getAllCalendars()Calendar[]ユーザーがオーナーまたは登録しているすべてのカレンダーを取得します。
getAllOwnedCalendars()Calendar[]ユーザーが所有するすべてのカレンダーを取得します。
getCalendarById(id)Calendar指定された ID のカレンダーを取得します。
getCalendarsByName(name)Calendar[]指定した名前でユーザーがオーナーまたは登録しているすべてのカレンダーを取得します。
getColor()Stringカレンダーの色を取得します。
getDefaultCalendar()Calendarユーザーのデフォルトのカレンダーを取得します。
getDescription()Stringカレンダーの説明を取得します。
getEventById(iCalId)CalendarEvent指定された ID のイベントを取得します。
getEventSeriesById(iCalId)CalendarEventSeries指定された ID のイベント シリーズを取得します。
getEvents(startTime, endTime)CalendarEvent[]指定された時間範囲内のすべてのイベントを取得します。
getEvents(startTime, endTime, options)CalendarEvent[]指定された期間内に発生し、指定された基準を満たすすべてのイベントを取得します。
getEventsForDay(date)CalendarEvent[]特定の日付に発生したすべてのイベントを取得します。
getEventsForDay(date, options)CalendarEvent[]特定の日付に発生し、指定された基準を満たすすべてのイベントを取得します。
getId()Stringカレンダーの ID を取得します。
getName()Stringカレンダーの名前を取得します。
getOwnedCalendarById(id)Calendarユーザーがカレンダーを所有している場合、指定された ID のカレンダーを取得します。
getOwnedCalendarsByName(name)Calendar[]ユーザーが所有する特定の名前のカレンダーをすべて取得します。
getTimeZone()Stringカレンダーのタイムゾーンを取得します。
isHidden()Booleanカレンダーをユーザー インターフェースで非表示にするかどうかを指定します。
isMyPrimaryCalendar()Boolean有効ユーザーのデフォルト カレンダーを指定します。
isOwnedByMe()Booleanカレンダーを自分がオーナーであるかどうかを指定します。
isSelected()Booleanユーザー インターフェースでカレンダーの予定を表示するかどうかを指定します。
newRecurrence()EventRecurrence新しい繰り返しオブジェクトを作成します。このオブジェクトを使用して、イベントの繰り返しに関するルールを作成できます。
setColor(color)Calendarカレンダーの色を設定します。
setDescription(description)Calendarカレンダーの説明を設定します。
setHidden(hidden)Calendarカレンダーをユーザー インターフェースに表示するかどうかを設定します。
setName(name)Calendarカレンダーの名前を設定します。
setSelected(selected)Calendarユーザー インターフェースでカレンダーの予定を表示するかどうかを設定します。
setTimeZone(timeZone)Calendarカレンダーのタイムゾーンを設定します。
subscribeToCalendar(id)Calendar特定の ID を使用してユーザーをカレンダーに登録します(ユーザーが登録を許可されている場合)。
subscribeToCalendar(id, options)Calendar特定の ID を使用してユーザーをカレンダーに登録します(ユーザーが登録を許可されている場合)。

詳細なドキュメント

createAllDayEvent(title, date)

終日の予定を作成します。

// Creates an all-day event for the moon landing and logs the ID.
var event = CalendarApp.getDefaultCalendar().createAllDayEvent('Apollo 11 Landing',
    new Date('July 20, 1969'));
Logger.log('Event ID: ' + event.getId());

パラメータ

Name説明
titleStringイベントのタイトル。
dateDate予定の日付(日のみを使用し、時刻は無視されます)。

復路

CalendarEvent - 作成されたイベント。

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

createAllDayEvent(title, startDate, endDate)

数日にわたる新しい終日の予定を作成します。

// Creates an all-day event for the Woodstock festival (August 15th to 17th) and logs the ID.
var event = CalendarApp.getDefaultCalendar().createAllDayEvent('Woodstock Festival',
    new Date('August 15, 1969'),
    new Date('August 18, 1969'));
Logger.log('Event ID: ' + event.getId());

パラメータ

Name説明
titleStringイベントのタイトル。
startDateDateイベントの開始日(時間のみが使用されます。時間は無視されます)。
endDateDateイベントの終了日(時刻のみが使用されます。時刻は無視されます)。終了日は含まれません。

復路

CalendarEvent - 作成されたイベント。

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

createAllDayEvent(title, startDate, endDate, options)

数日にわたる新しい終日の予定を作成します。

// Creates an all-day event for the Woodstock festival (August 15th to 17th) and logs the ID.
var event = CalendarApp.getDefaultCalendar().createAllDayEvent('Woodstock Festival',
    new Date('August 15, 1969'),
    new Date('August 18, 1969'),
    {location: 'Bethel, White Lake, New York, U.S.', sendInvites: true});
Logger.log('Event ID: ' + event.getId());

パラメータ

Name説明
titleStringイベントのタイトル。
startDateDateイベントの開始日(時間のみが使用されます。時間は無視されます)。
endDateDateイベントの終了日(時刻のみが使用されます。時刻は無視されます)。終了日は含まれません。
optionsObject下記の詳細なパラメータを指定する JavaScript オブジェクト。

拡張パラメータ

Name説明
descriptionStringイベントの説明。
locationStringイベントの場所。
guestsStringゲストとして追加する必要があるメールアドレスのカンマ区切りリスト。
sendInvitesBoolean招待メールを送信するかどうか(デフォルト: false)。

復路

CalendarEvent - 作成されたイベント。

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

createAllDayEvent(title, date, options)

終日の予定を作成します。

// Creates an all-day event for the moon landing and logs the ID.
var event = CalendarApp.getDefaultCalendar().createAllDayEvent('Apollo 11 Landing',
    new Date('July 20, 1969'),
    {location: 'The Moon'});
Logger.log('Event ID: ' + event.getId());

パラメータ

Name説明
titleStringイベントのタイトル。
dateDate予定の日付(日のみを使用し、時刻は無視されます)。
optionsObject下記の詳細なパラメータを指定する JavaScript オブジェクト。

拡張パラメータ

Name説明
descriptionStringイベントの説明。
locationStringイベントの場所。
guestsStringゲストとして追加する必要があるメールアドレスのカンマ区切りリスト。
sendInvitesBoolean招待メールを送信するかどうか(デフォルト: false)。

復路

CalendarEvent - 作成されたイベント。

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

createAllDayEventSeries(title, startDate, recurrence)

終日の予定を作成します。

// Creates an event series for a no-meetings day, taking place every Wednesday in 2013.
var eventSeries = CalendarApp.getDefaultCalendar().createAllDayEventSeries('No Meetings',
    new Date('January 2, 2013 03:00:00 PM EST'),
    CalendarApp.newRecurrence().addWeeklyRule()
        .onlyOnWeekday(CalendarApp.Weekday.WEDNESDAY)
        .until(new Date('January 1, 2014')));
Logger.log('Event Series ID: ' + eventSeries.getId());

パラメータ

Name説明
titleString一連のイベントのタイトル
startDateDate一連の最初のイベントの日付(時間のみが使用され、時間は無視されます)
recurrenceEventRecurrence一連の定期的な予定の設定

復路

CalendarEventSeries - 作成されたイベント系列

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

createAllDayEventSeries(title, startDate, recurrence, options)

終日の予定を作成します。

// Creates an event series for a no-meetings day, taking place every Wednesday in 2013.
var eventSeries = CalendarApp.getDefaultCalendar().createAllDayEventSeries('No Meetings',
    new Date('January 2, 2013 03:00:00 PM EST'),
    CalendarApp.newRecurrence().addWeeklyRule()
        .onlyOnWeekday(CalendarApp.Weekday.WEDNESDAY)
        .until(new Date('January 1, 2014')),
    {guests: 'everyone@example.com'});
Logger.log('Event Series ID: ' + eventSeries.getId());

パラメータ

Name説明
titleString一連のイベントのタイトル
startDateDate一連の最初のイベントの日付(時間のみが使用され、時間は無視されます)
recurrenceEventRecurrence一連の定期的な予定の設定
optionsObject高度なパラメータを指定する JavaScript オブジェクト(下記参照)

拡張パラメータ

Name説明
descriptionString一連のイベントの説明
locationString一連の予定の場所
guestsString一連のイベントにゲストとして追加するメールアドレスのカンマ区切りリスト
sendInvitesBoolean招待メールを送信するかどうか(デフォルト: false

復路

CalendarEventSeries - 作成されたイベント系列

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

createCalendar(name)

ユーザーが所有する新しいカレンダーを作成します。

// Creates a new calendar named "Travel Plans".
var calendar = CalendarApp.createCalendar('Travel Plans');
Logger.log('Created the calendar "%s", with the ID "%s".',
    calendar.getName(), calendar.getId());

パラメータ

Name説明
nameString新しいカレンダーの名前

復路

Calendar - 新しく作成されたカレンダー。

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

createCalendar(name, options)

ユーザーが所有する新しいカレンダーを作成します。

// Creates a new calendar named "Travel Plans" with a summary and color.
var calendar = CalendarApp.createCalendar('Travel Plans', {
  summary: 'A calendar to plan my travel schedule.',
  color: CalendarApp.Color.BLUE
});
Logger.log('Created the calendar "%s", with the ID "%s".',
    calendar.getName(), calendar.getId());

パラメータ

Name説明
nameString新しいカレンダーの名前
optionsObject高度なパラメータを指定する JavaScript オブジェクト(下記参照)

拡張パラメータ

Name説明
locationStringカレンダーの場所
summaryStringカレンダーの説明
timeZoneStringカレンダーに設定するタイムゾーン。「long」形式で指定します(例:「America/New_York」(Joda.org を参照)
colorString16 進数のカラー文字列(「#rrggbb」)、または CalendarApp.Colors の値
hiddenBooleanユーザー インターフェースでカレンダーを非表示にするかどうか(デフォルト: false)。
selectedBooleanカレンダーの予定をユーザー インターフェースに表示するかどうか(デフォルト: true)。

復路

Calendar - 新しく作成されたカレンダー。

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

createEvent(title, startTime, endTime)

新しいイベントを作成します。

タイムゾーンが指定されていない場合、時刻の値はスクリプトのタイムゾーンのコンテキストとして解釈されます。これは、カレンダーのタイムゾーンとは異なる場合があります。

// Creates an event for the moon landing and logs the ID.
var event = CalendarApp.getDefaultCalendar().createEvent('Apollo 11 Landing',
    new Date('July 20, 1969 20:00:00 UTC'),
    new Date('July 21, 1969 21:00:00 UTC'));
Logger.log('Event ID: ' + event.getId());

パラメータ

Name説明
titleStringイベントのタイトル
startTimeDateイベントの開始日時
endTimeDate予定の終了日時

復路

CalendarEvent - 作成されたイベント

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

createEvent(title, startTime, endTime, options)

新しいイベントを作成します。

タイムゾーンが指定されていない場合、時刻の値はスクリプトのタイムゾーンのコンテキストとして解釈されます。これは、カレンダーのタイムゾーンとは異なる場合があります。

// Creates an event for the moon landing and logs the ID.
var event = CalendarApp.getDefaultCalendar().createEvent('Apollo 11 Landing',
    new Date('July 20, 1969 20:00:00 UTC'),
    new Date('July 20, 1969 21:00:00 UTC'),
    {location: 'The Moon'});
Logger.log('Event ID: ' + event.getId());

パラメータ

Name説明
titleStringイベントのタイトル
startTimeDateイベントの開始日時
endTimeDate予定の終了日時
optionsObject高度なパラメータを指定する JavaScript オブジェクト(下記参照)

拡張パラメータ

Name説明
descriptionStringイベントの説明
locationStringイベントの場所
guestsStringゲストとして追加する必要があるメールアドレスのカンマ区切りリスト
sendInvitesBoolean招待メールを送信するかどうか(デフォルト: false

復路

CalendarEvent - 作成されたイベント

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

createEventFromDescription(description)

自由形式の説明からイベントを作成します。

説明は、UI の「クイック追加」機能と同じ形式を使用する必要があります。

// Creates a new event and logs its ID.
var event = CalendarApp.getDefaultCalendar()
    .createEventFromDescription('Lunch with Mary, Friday at 1PM');
Logger.log('Event ID: ' + event.getId());

パラメータ

Name説明
descriptionStringイベントに関する自由形式の説明

復路

CalendarEvent - 作成されたイベント

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

createEventSeries(title, startTime, endTime, recurrence)

新しいイベント系列を作成します。

// Creates an event series for a team meeting, taking place every Tuesday and Thursday in 2013.
var eventSeries = CalendarApp.getDefaultCalendar().createEventSeries('Team Meeting',
    new Date('January 1, 2013 03:00:00 PM EST'),
    new Date('January 1, 2013 04:00:00 PM EST'),
    CalendarApp.newRecurrence().addWeeklyRule()
        .onlyOnWeekdays([CalendarApp.Weekday.TUESDAY, CalendarApp.Weekday.THURSDAY])
        .until(new Date('January 1, 2014')));
Logger.log('Event Series ID: ' + eventSeries.getId());

パラメータ

Name説明
titleString一連のイベントのタイトル
startTimeDate一連の定期的な予定の開始日時
endTimeDate一連の予定の最初のイベントが終了する日時
recurrenceEventRecurrence一連の定期的な予定の設定

復路

CalendarEventSeries - 作成されたイベント系列

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

createEventSeries(title, startTime, endTime, recurrence, options)

新しいイベント系列を作成します。

// Creates an event series for a team meeting, taking place every Tuesday and Thursday in 2013.
var eventSeries = CalendarApp.getDefaultCalendar().createEventSeries('Team Meeting',
    new Date('January 1, 2013 03:00:00 PM EST'),
    new Date('January 1, 2013 04:00:00 PM EST'),
    CalendarApp.newRecurrence().addWeeklyRule()
        .onlyOnWeekdays([CalendarApp.Weekday.TUESDAY, CalendarApp.Weekday.THURSDAY])
        .until(new Date('January 1, 2014')),
    {location: 'Conference Room'});
Logger.log('Event Series ID: ' + eventSeries.getId());

パラメータ

Name説明
titleString一連のイベントのタイトル
startTimeDate一連の定期的な予定の開始日時
endTimeDate一連の予定の最初のイベントが終了する日時
recurrenceEventRecurrence一連の定期的な予定の設定
optionsObject高度なパラメータを指定する JavaScript オブジェクト(下記参照)

拡張パラメータ

Name説明
descriptionString一連のイベントの説明
locationString一連の予定の場所
guestsString一連のイベントにゲストとして追加するメールアドレスのカンマ区切りリスト
sendInvitesBoolean招待メールを送信するかどうか(デフォルト: false

復路

CalendarEventSeries - 作成されたイベント系列

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

getAllCalendars()

ユーザーがオーナーまたは登録しているすべてのカレンダーを取得します。

// Determines how many calendars the user can access.
var calendars = CalendarApp.getAllCalendars();
Logger.log('This user owns or is subscribed to %s calendars.',
    calendars.length);

復路

Calendar[] - ユーザーがアクセスできるすべてのカレンダー

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getAllOwnedCalendars()

ユーザーが所有するすべてのカレンダーを取得します。

// Determines how many calendars the user owns.
var calendars = CalendarApp.getAllOwnedCalendars();
Logger.log('This user owns %s calendars.', calendars.length);

復路

Calendar[] - ユーザーが所有するすべてのカレンダー

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getCalendarById(id)

指定された ID のカレンダーを取得します。

// Gets the public calendar "US Holidays" by ID.
var calendar = CalendarApp.getCalendarById(
    'en.usa#holiday@group.v.calendar.google.com');
Logger.log('The calendar is named "%s".', calendar.getName());

パラメータ

Name説明
idStringカレンダー ID

復路

Calendar - 指定された ID を持つカレンダー、またはカレンダーが存在しない場合、ユーザーがアクセスできない場合、またはユーザーがカレンダーに登録していない場合は null です。

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getCalendarsByName(name)

指定した名前でユーザーがオーナーまたは登録しているすべてのカレンダーを取得します。大文字と小文字は区別されません。

// Gets the public calendar named "US Holidays".
var calendars = CalendarApp.getCalendarsByName('US Holidays');
Logger.log('Found %s matching calendars.', calendars.length);

パラメータ

Name説明
nameStringカレンダー名

復路

Calendar[] - ユーザーがアクセスできる、この名前を持つすべてのカレンダー

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getColor()

カレンダーの色を取得します。

復路

String - 16 進数のカラー文字列(#rrggbb)

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getDefaultCalendar()

ユーザーのデフォルトのカレンダーを取得します。

// Determines the time zone of the user's default calendar.
var calendar = CalendarApp.getDefaultCalendar();
Logger.log('My default calendar is set to the time zone "%s".',
    calendar.getTimeZone());

復路

Calendar - ユーザーのデフォルトのカレンダー

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getDescription()

カレンダーの説明を取得します。

復路

String - このカレンダーの説明

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getEventById(iCalId)

指定された ID のイベントを取得します。シリーズがデフォルト カレンダー以外のカレンダーに属している場合、このメソッドはそのカレンダーから呼び出す必要があります。getEventById(iCalId) を呼び出すと、デフォルトのカレンダー内の予定のみが返されます。

1 つのイベント シリーズ内であれば、複数のイベントで同じ ID を持つことがあります。この場合、このメソッドはそのシリーズの最初のイベントのみを返します。

パラメータ

Name説明
iCalIdStringイベントの ID

復路

CalendarEvent - 指定された ID を持つイベント。イベントが存在しない場合、またはユーザーがイベントにアクセスできない場合は、null

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getEventSeriesById(iCalId)

指定された ID のイベント シリーズを取得します。指定された ID が単一の CalendarEvent に対するものである場合、一連の単一のイベントに対して CalendarEventSeries が返されます。イベント シリーズがデフォルト カレンダー以外のカレンダーに属している場合、このメソッドはその CalendarApp から呼び出す必要があります。getEventSeriesById(iCalId) を直接呼び出すと、デフォルト カレンダー内に存在するイベント シリーズのみが返されます。

パラメータ

Name説明
iCalIdStringイベント系列の ID

復路

CalendarEventSeries - 指定された ID を持つシリーズ。シリーズが存在しない場合、またはユーザーがアクセスできない場合。null

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getEvents(startTime, endTime)

指定された時間範囲内のすべてのイベントを取得します。

このメソッドは、指定された期間内で開始されたイベント、特定の期間内で終了したイベント、または指定期間内のイベントを返します。タイムゾーンが指定されていない場合、時刻の値はスクリプトのタイムゾーンのコンテキストとして解釈されます。これは、タイムゾーンのタイムゾーンとは異なる場合があります。

// Determines how many events are happening in the next two hours.
var now = new Date();
var twoHoursFromNow = new Date(now.getTime() + (2 * 60 * 60 * 1000));
var events = CalendarApp.getDefaultCalendar().getEvents(now, twoHoursFromNow);
Logger.log('Number of events: ' + events.length);

パラメータ

Name説明
startTimeDate期間の開始
endTimeDate期間の終了時(指定不可)

復路

CalendarEvent[] - 期間内に発生したイベント

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getEvents(startTime, endTime, options)

指定された期間内に発生し、指定された基準を満たすすべてのイベントを取得します。

このメソッドは、指定期間内で開始されたイベント、指定期間中に終了したイベント、または指定期間イベントを含むイベントを返します。タイムゾーンが指定されていない場合、時刻の値はスクリプトのタイムゾーンのコンテキストとして解釈されます。これは、タイムゾーンのタイムゾーンとは異なる場合があります。

authorsearchstatusFilters でのフィルタリングは、startmax の適用後に行われます。つまり、追加のイベントが条件を満たしている場合でも、返されるイベント数が max 未満になる場合があります。

// Determines how many events are happening in the next two hours that contain the term
// "meeting".
var now = new Date();
var twoHoursFromNow = new Date(now.getTime() + (2 * 60 * 60 * 1000));
var events = CalendarApp.getDefaultCalendar().getEvents(now, twoHoursFromNow,
    {search: 'meeting'});
Logger.log('Number of events: ' + events.length);

パラメータ

Name説明
startTimeDate期間の開始
endTimeDate期間の終了時(指定不可)
optionsObject高度なパラメータを指定する JavaScript オブジェクト(下記参照)

拡張パラメータ

Name説明
startInteger返される最初のイベントのインデックス
maxInteger返される最大イベント数
authorStringイベント作成者による結果のフィルタリングに使用されるメールアドレス
searchString結果のフィルタリングに使用される全文検索クエリ
statusFilters[]GuestStatus結果のフィルタリングに使用されるステータスの配列

復路

CalendarEvent[] - 特定の期間に発生し、条件に一致するイベント

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getEventsForDay(date)

特定の日に発生したすべてのイベントを取得します。

このメソッドは、特定の日の開始時刻、当日の終了、または当日を含むイベントを返します。

Date オブジェクトの日付部分のみが使用され、時間部分は無視されます。この日付は、カレンダーのタイムゾーンの午前 0 時から翌日の午前 0 時までが解釈されます。

// Determines how many events are happening today.
var today = new Date();
var events = CalendarApp.getDefaultCalendar().getEventsForDay(today);
Logger.log('Number of events: ' + events.length);

パラメータ

Name説明
dateDate予定を取得する日付です(日付のみが使用されます。時間は無視されます)。

復路

CalendarEvent[] - 特定の日付に発生したイベント

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getEventsForDay(date, options)

特定の日付に発生し、指定された基準を満たすすべてのイベントを取得します。

このメソッドは、特定の日の開始時刻、当日の終了、または当日を含むイベントを返します。

Date オブジェクトの日付部分のみが使用され、時間部分は無視されます。この日付は、カレンダーのタイムゾーンの午前 0 時から翌日の午前 0 時までが解釈されます。

authorsearchstatusFilters でのフィルタリングは、startmax の適用後に行われます。つまり、追加のイベントが条件を満たしている場合でも、返されるイベント数が max 未満になる場合があります。

// Determines how many events are happening today and contain the term "meeting".
var today = new Date();
var events = CalendarApp.getDefaultCalendar().getEventsForDay(today, {search: 'meeting'});
Logger.log('Number of events: ' + events.length);

パラメータ

Name説明
dateDate予定を取得する日付です(日付のみが使用されます。時間は無視されます)。
optionsObject高度なフィルタ オプション

拡張パラメータ

Name説明
startInteger返される最初のイベントのインデックス
maxInteger返される最大イベント数
authorStringイベント作成者による結果のフィルタリングに使用されるメールアドレス
searchString結果のフィルタリングに使用される全文検索クエリ
statusFilters[]GuestStatus結果のフィルタリングに使用されるステータスの配列

復路

CalendarEvent[] - 特定の日付に発生し、基準と一致するイベント

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getId()

カレンダーの ID を取得します。ユーザーのデフォルト カレンダーの ID はユーザーのメールアドレスです。

復路

String - カレンダーの ID

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getName()

カレンダーの名前を取得します。

復路

String - このカレンダーの名前

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getOwnedCalendarById(id)

ユーザーがカレンダーを所有している場合、指定された ID のカレンダーを取得します。

カレンダー ID を確認するには、Google カレンダーでカレンダー名の横にある矢印をクリックして [カレンダーの設定] を選択します。この ID は設定ページの下部に表示されます。

// Gets a (non-existent) private calendar by ID.
var calendar = CalendarApp.getOwnedCalendarById(
    '123456789@group.calendar.google.com');
Logger.log('The calendar is named "%s".', calendar.getName());

パラメータ

Name説明
idStringカレンダー ID

復路

Calendar - 指定された ID を持つカレンダー。カレンダーが存在しない場合またはユーザーがカレンダーを所有していない場合は null します。

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getOwnedCalendarsByName(name)

ユーザーが所有する特定の名前のカレンダーをすべて取得します。大文字と小文字は区別されません。

// Gets a private calendar named "Travel Plans".
var calendars = CalendarApp.getOwnedCalendarsByName('Travel Plans');
Logger.log('Found %s matching calendars.', calendars.length);

パラメータ

Name説明
nameStringカレンダー名

復路

Calendar[] - ユーザーがオーナーとなっている、この名前を持つすべてのカレンダー

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getTimeZone()

カレンダーのタイムゾーンを取得します。

復路

String - 「long」形式で指定されたタイムゾーン(Joda.org のリスト「America/New_York」など)。

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

isHidden()

カレンダーをユーザー インターフェースで非表示にするかどうかを指定します。

復路

Boolean - ユーザー カレンダーでカレンダーが非表示になっている場合は true、そうでない場合は false です。

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

isMyPrimaryCalendar()

有効ユーザーのデフォルト カレンダーを指定します。

復路

Boolean - 有効ユーザーのデフォルト カレンダーの場合は true、そうでない場合は false

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

isOwnedByMe()

カレンダーを自分がオーナーであるかどうかを指定します。

// Gets a calendar by its ID. To get the user's default calendar, use
// CalendarApp.getDefault() instead.
// TODO(developer): Replace the ID with the calendar ID that you want to use.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Determines whether the calendar is owned by you and logs it.
console.log(calendar.isOwnedByMe());

復路

Boolean - 自分がオーナーのカレンダーの場合は true、そうでない場合は false

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

isSelected()

ユーザー インターフェースでカレンダーの予定を表示するかどうかを指定します。

// Gets the user's default calendar. To get a different calendar, use getCalendarById()
// instead.
const calendar = CalendarApp.getDefaultCalendar();

// Determines whether the calendar's events are displayed in the user interface and logs it.
console.log(calendar.isSelected());

復路

Boolean - ユーザー インターフェースでカレンダーの予定を表示する場合は true、それ以外の場合は false

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

newRecurrence()

新しい繰り返しオブジェクトを作成します。このオブジェクトを使用して、繰り返しタスクのルールを作成できます。

// Creates an event series for a no-meetings day, taking place every Wednesday in 2013.
var recurrence = CalendarApp.newRecurrence().addWeeklyRule()
    .onlyOnWeekday(CalendarApp.Weekday.WEDNESDAY)
    .until(new Date('January 1, 2014'));
var eventSeries = CalendarApp.getDefaultCalendar().createAllDayEventSeries('No Meetings',
    new Date('January 2, 2013 03:00:00 PM EST'),
    recurrence);
Logger.log('Event Series ID: ' + eventSeries.getId());

復路

EventRecurrence - ルールが設定されていない新しい繰り返しオブジェクト(毎週の繰り返しとして動作)

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

setColor(color)

カレンダーの色を設定します。

// Gets the user's default calendar. To get a different calendar, use getCalendarById()
// instead.
const calendar = CalendarApp.getDefaultCalendar();

// Sets the color of the calendar to pink.
calendar.setColor(CalendarApp.Color.PINK);

パラメータ

Name説明
colorStringCalendarApp.Color または 16 進数のカラー文字列(#rrggbb)。

復路

Calendar - 連結用のカレンダー。

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

setDescription(description)

カレンダーの説明を設定します。

// Gets the user's default calendar. To get a different calendar, use getCalendarById()
// instead.
const calendar = CalendarApp.getDefaultCalendar();

// Sets the description of the calendar.
// TODO(developer): Update the string with the description that you want to use.
calendar.setDescription('Updated calendar description.')

パラメータ

Name説明
descriptionStringこのカレンダーの説明

復路

Calendar - 連結用のカレンダー

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

setHidden(hidden)

カレンダーをユーザー インターフェースに表示するかどうかを設定します。

パラメータ

Name説明
hiddenBooleantrueユーザー インターフェースではカレンダーを非表示にできます。false

復路

Calendar - 連結用のカレンダー

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

setName(name)

カレンダーの名前を設定します。

// Gets the user's default calendar. To get a different calendar, use getCalendarById()
// instead.
const calendar = CalendarApp.getDefaultCalendar();

// Sets the name of the calendar.
// TODO(developer): Update the string with the name that you want to use.
calendar.setName('Example calendar name');

パラメータ

Name説明
nameString新しい名前

復路

Calendar - 連結用のカレンダー

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

setSelected(selected)

ユーザー インターフェースでカレンダーの予定を表示するかどうかを設定します。

// Gets the user's default calendar. To get a different calendar, use getCalendarById()
// instead.
const calendar = CalendarApp.getDefaultCalendar();

// Selects the calendar so that its events are displayed in the user interface. To
// unselect the calendar, set the parameter to false.
calendar.setSelected(true);

パラメータ

Name説明
selectedBooleanユーザー インターフェースでカレンダーの予定を表示する場合は true、非表示にする場合は false です。

復路

Calendar - 連結用のカレンダー

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

setTimeZone(timeZone)

カレンダーのタイムゾーンを設定します。

// Gets the user's default calendar. To get a different calendar, use getCalendarById()
// instead.
const calendar = CalendarApp.getDefaultCalendar();

// Sets the time zone of the calendar to America/New York (US/Eastern) time.
calendar.setTimeZone('America/New_York');

パラメータ

Name説明
timeZoneString「long」形式で指定されたタイムゾーン(Joda.org に表示される「America/New_York」など)。

復路

Calendar - 連結用のカレンダー。

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

subscribeToCalendar(id)

ユーザーが登録を許可されている場合に、指定された ID でユーザーをカレンダーに登録します。

// Subscribe to the calendar "US Holidays".
var calendar = CalendarApp.subscribeToCalendar(
    'en.usa#holiday@group.v.calendar.google.com');
Logger.log('Subscribed to the calendar "%s".', calendar.getName());

パラメータ

Name説明
idString登録するカレンダーの ID

復路

Calendar - 新しくカレンダーに登録されたカレンダー

例外

Error - この ID を持つカレンダーが存在しない場合

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

subscribeToCalendar(id, options)

ユーザーが登録を許可されている場合に、指定された ID でユーザーをカレンダーに登録します。

// Subscribe to the calendar "US Holidays", and set it to the color blue.
var calendar = CalendarApp.subscribeToCalendar(
    'en.usa#holiday@group.v.calendar.google.com',
    { color: CalendarApp.Color.BLUE });
Logger.log('Subscribed to the calendar "%s".', calendar.getName());

パラメータ

Name説明
idString登録するカレンダーの ID
optionsObject高度なパラメータを指定する JavaScript オブジェクト(下記参照)

拡張パラメータ

Name説明
colorString16 進数のカラー文字列(「#rrggbb」)、または CalendarApp.Colors の値
hiddenBooleanユーザー インターフェースでカレンダーを非表示にするかどうか(デフォルト: false)。
selectedBooleanカレンダーの予定をユーザー インターフェースに表示するかどうか(デフォルト: true)。

復路

Calendar - 新しく登録したカレンダー

例外

Error - この ID を持つカレンダーが存在しない場合

認証

このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds