ユーザーの Google カレンダーの読み取りと更新をスクリプトに許可します。このクラスを使用すると、ユーザーのデフォルト カレンダーに直接アクセスできるだけでなく、ユーザーが所有または登録している追加のカレンダーを取得できます。
プロパティ
プロパティ | タイプ | 説明 |
---|---|---|
Color | Color | カレンダー サービスで使用可能な名前付きの色を表す列挙型。 |
EventColor | EventColor | カレンダー サービスで使用可能な名前付き予定の色を表す列挙型。 |
GuestStatus | GuestStatus | イベントでゲストに付与できるステータスを表す列挙型。 |
Month | Month | 月を表す列挙型。 |
Visibility | Visibility | イベントの表示状態を表す列挙型。 |
Weekday | Weekday | 曜日を表す列挙型。 |
メソッド
詳細なドキュメント
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());
パラメータ
名前 | 型 | 説明 |
---|---|---|
title | String | イベントのタイトル。 |
date | Date | イベントの日付(日付のみが使用され、時刻は無視されます)。 |
リターン
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());
パラメータ
名前 | 型 | 説明 |
---|---|---|
title | String | イベントのタイトル。 |
startDate | Date | イベントの開始日(日付のみが使用され、時刻は無視されます)。 |
endDate | Date | イベントの終了日(日付のみが使用され、時刻は無視されます)。終了日は含まれません。 |
リターン
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());
パラメータ
名前 | 型 | 説明 |
---|---|---|
title | String | イベントのタイトル。 |
startDate | Date | イベントの開始日(日付のみが使用され、時刻は無視されます)。 |
endDate | Date | イベントの終了日(日付のみが使用され、時刻は無視されます)。終了日は含まれません。 |
options | Object | 詳細パラメータを指定する JavaScript オブジェクト。下記をご覧ください。 |
拡張パラメータ
名前 | 型 | 説明 |
---|---|---|
description | String | イベントの説明。 |
location | String | イベントの場所。 |
guests | String | ゲストとして追加するメールアドレスのカンマ区切りのリスト。 |
sendInvites | Boolean | 招待メールを送信するかどうか(デフォルト: 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());
パラメータ
名前 | 型 | 説明 |
---|---|---|
title | String | イベントのタイトル。 |
date | Date | イベントの日付(日付のみが使用され、時刻は無視されます)。 |
options | Object | 詳細パラメータを指定する JavaScript オブジェクト。下記をご覧ください。 |
拡張パラメータ
名前 | 型 | 説明 |
---|---|---|
description | String | イベントの説明。 |
location | String | イベントの場所。 |
guests | String | ゲストとして追加するメールアドレスのカンマ区切りのリスト。 |
sendInvites | Boolean | 招待メールを送信するかどうか(デフォルト: 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());
パラメータ
名前 | 型 | 説明 |
---|---|---|
title | String | 一連の定期的な予定のタイトル |
startDate | Date | 一連の繰り返しの最初のイベントの日付(日付のみが使用され、時刻は無視されます) |
recurrence | EventRecurrence | 一連の定期的な予定の繰り返し設定 |
リターン
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());
パラメータ
名前 | 型 | 説明 |
---|---|---|
title | String | 一連の定期的な予定のタイトル |
startDate | Date | 一連の繰り返しの最初のイベントの日付(日付のみが使用され、時刻は無視されます) |
recurrence | EventRecurrence | 一連の定期的な予定の繰り返し設定 |
options | Object | 詳細パラメータを指定する JavaScript オブジェクト |
拡張パラメータ
名前 | 型 | 説明 |
---|---|---|
description | String | 一連のイベントの説明 |
location | String | 一連のイベントの場所 |
guests | String | 一連のイベントにゲストとして追加するメールアドレスのカンマ区切りのリスト |
sendInvites | Boolean | 招待メールを送信するかどうか(デフォルト: 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 | String | 新しいカレンダーの名前 |
リターン
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 | String | 新しいカレンダーの名前 |
options | Object | 詳細パラメータを指定する JavaScript オブジェクト |
拡張パラメータ
名前 | 型 | 説明 |
---|---|---|
location | String | カレンダーの場所 |
summary | String | カレンダーの説明 |
timeZone | String | カレンダーを設定するタイムゾーン。「long」形式で指定します(例:「America/New_York」、Joda.org によりリストされている) |
color | String | 16 進数の色文字列(「#rrggbb」)または CalendarApp.Colors の値 |
hidden | Boolean | ユーザー インターフェースでカレンダーが非表示かどうか(デフォルト: false ) |
selected | Boolean | カレンダーの予定をユーザー インターフェースに表示するかどうか(デフォルト: 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());
パラメータ
名前 | 型 | 説明 |
---|---|---|
title | String | 予定のタイトル |
startTime | Date | イベントの開始日時 |
endTime | Date | 予定の終了日時 |
リターン
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());
パラメータ
名前 | 型 | 説明 |
---|---|---|
title | String | 予定のタイトル |
startTime | Date | イベントの開始日時 |
endTime | Date | 予定の終了日時 |
options | Object | 詳細パラメータを指定する JavaScript オブジェクト |
拡張パラメータ
名前 | 型 | 説明 |
---|---|---|
description | String | イベントの説明 |
location | String | イベントの場所 |
guests | String | ゲストとして追加するメールアドレスのカンマ区切りのリスト |
sendInvites | Boolean | 招待メールを送信するかどうか(デフォルト: 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());
パラメータ
名前 | 型 | 説明 |
---|---|---|
description | String | イベントの説明(自由形式) |
リターン
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());
パラメータ
名前 | 型 | 説明 |
---|---|---|
title | String | 一連の定期的な予定のタイトル |
startTime | Date | 一連の定期的な予定の最初の予定の開始日時 |
endTime | Date | 一連の定期的な予定の最初の予定の終了日時 |
recurrence | EventRecurrence | 一連の定期的な予定の繰り返し設定 |
リターン
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());
パラメータ
名前 | 型 | 説明 |
---|---|---|
title | String | 一連の定期的な予定のタイトル |
startTime | Date | 一連の定期的な予定の最初の予定の開始日時 |
endTime | Date | 一連の定期的な予定の最初の予定の終了日時 |
recurrence | EventRecurrence | 一連の定期的な予定の繰り返し設定 |
options | Object | 詳細パラメータを指定する JavaScript オブジェクト |
拡張パラメータ
名前 | 型 | 説明 |
---|---|---|
description | String | 一連のイベントの説明 |
location | String | 一連のイベントの場所 |
guests | String | 一連のイベントにゲストとして追加するメールアドレスのカンマ区切りのリスト |
sendInvites | Boolean | 招待メールを送信するかどうか(デフォルト: 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());
パラメータ
名前 | 型 | 説明 |
---|---|---|
id | String | カレンダー 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 | String | カレンダー名 |
リターン
Calendar[]
- この名前でユーザーがアクセスできるすべてのカレンダー
認可
このメソッドを使用するスクリプトには、次のスコープのうち 1 つ以上による承認、または関連する REST API からの適切なスコープが必要です。
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
getColor()
カレンダーの色を取得します。
// Opens the calendar by its ID. // TODO(developer): Replace the ID with your own. const calendar = CalendarApp.getCalendarById('222larabrown@gmail.com'); // Gets the color of the calendar and logs it to the console. // For the default calendar, you can use CalendarApp.getColor() instead. const calendarColor = calendar.getColor(); console.log(calendarColor);
リターン
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()
カレンダーの説明を取得します。
// Opens the calendar by its ID. // TODO(developer): Replace the ID with your own. const calendar = CalendarApp.getCalendarById('222larabrown@gmail.com'); // Sets the description of the calendar to 'Test description.' calendar.setDescription('Test description'); // Gets the description of the calendar and logs it to the console. // For the default calendar, you can use CalendarApp.getDescription() instead. const description = calendar.getDescription(); console.log(description);
リターン
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)
を呼び出すと、デフォルトのカレンダーの予定のみが返されます。
一連のイベントに含まれるイベントが複数ある場合は、同じ ID を持つことができます。この場合、このメソッドは一連のイベントのうち最初のイベントのみを返します。
// Opens the calendar by its ID. // TODO(developer): Replace the ID with your own. const calendar = CalendarApp.getCalendarById('222larabrown@gmail.com') // Creates an event for the moon landing. const event = calendar.createEvent('Apollo 11 Landing', new Date('July 20, 1969 20:05:00 UTC'), new Date('July 20, 1969 20:17:00 UTC')); // Gets the calendar event ID and logs it to the console. const iCalId = event.getId(); console.log(iCalId); // Gets the event by its ID and logs the title of the event to the console. // For the default calendar, you can use CalendarApp.getEventById(iCalId) instead. const myEvent = calendar.getEventById(iCalId); console.log(myEvent.getTitle());
パラメータ
名前 | 型 | 説明 |
---|---|---|
iCalId | String | イベントの 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
に対するものである場合、一連の中の 1 つのイベントとともに CalendarEventSeries
が返されます。一連の予定がデフォルト カレンダー以外のカレンダーに属している場合、このメソッドはその CalendarApp
から呼び出す必要があります。getEventSeriesById(iCalId)
を直接呼び出すと、デフォルトのカレンダーに存在する一連の予定だけが返されます。
// Opens the calendar by its ID. // TODO(developer): Replace the ID with your own. const calendar = CalendarApp.getCalendarById('222larabrown@gmail.com'); // Creates an event series for a daily team meeting from 1 PM to 2 PM. // The series adds the daily event from January 1, 2023 through December 31, 2023. const eventSeries = calendar.createEventSeries('Team meeting', new Date('Jan 1, 2023 13:00:00'), new Date('Jan 1, 2023 14:00:00'), CalendarApp.newRecurrence().addDailyRule().until(new Date('Jan 1, 2024'))); // Gets the ID of the event series. const iCalId = eventSeries.getId(); // Gets the event series by its ID and logs the series title to the console. // For the default calendar, you can use CalendarApp.getEventSeriesById(iCalId) instead. console.log(calendar.getEventSeriesById(iCalId).getTitle());
パラメータ
名前 | 型 | 説明 |
---|---|---|
iCalId | String | イベント シリーズの 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);
パラメータ
名前 | 型 | 説明 |
---|---|---|
startTime | Date | 期間の開始時 |
endTime | Date | 期間の終了値(この値を含まない) |
リターン
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)
特定の期間内に発生し、指定された条件を満たすすべてのイベントを取得します。
このメソッドは、指定された期間内に開始されたイベント、指定された期間内に終了するイベント、または特定の期間を含むイベントを返します。タイムゾーンが指定されていない場合、時刻の値はスクリプトのタイムゾーンのコンテキストで解釈されます。これは、カレンダーのタイムゾーンとは異なる場合があります。
author
、search
、statusFilters
でのフィルタリングは、start
と max
を適用した後に実行されることに注意してください。つまり、他のイベントが条件を満たしていても、返されるイベントの数が 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);
パラメータ
名前 | 型 | 説明 |
---|---|---|
startTime | Date | 期間の開始時 |
endTime | Date | 期間の終了値(この値を含まない) |
options | Object | 詳細パラメータを指定する JavaScript オブジェクト |
拡張パラメータ
名前 | 型 | 説明 |
---|---|---|
start | Integer | 返される最初のイベントのインデックス |
max | Integer | 返されるイベントの最大数 |
author | String | イベント作成者による結果のフィルタリングに使用するメールアドレス |
search | String | 検索結果のフィルタリングに使用する全文検索クエリ |
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);
パラメータ
名前 | 型 | 説明 |
---|---|---|
date | Date | イベントを取得する日付(日付のみが使用され、時間は無視されます) |
リターン
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 時までと解釈されます。
author
、search
、statusFilters
でのフィルタリングは、start
と max
を適用した後に実行されることに注意してください。つまり、他のイベントが条件を満たしていても、返されるイベントの数が 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);
パラメータ
名前 | 型 | 説明 |
---|---|---|
date | Date | イベントを取得する日付(日付のみが使用され、時間は無視されます) |
options | Object | 高度なフィルタ オプション |
拡張パラメータ
名前 | 型 | 説明 |
---|---|---|
start | Integer | 返される最初のイベントのインデックス |
max | Integer | 返されるイベントの最大数 |
author | String | イベント作成者による結果のフィルタリングに使用するメールアドレス |
search | String | 検索結果のフィルタリングに使用する全文検索クエリ |
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 は、ユーザーのメールアドレスです。
// Opens the calendar by its ID. // To get the user's default calendar, use CalendarApp.getDefaultCalendar(). // TODO(developer): Replace the ID with your own. const calendar = CalendarApp.getCalendarById('222larabrown@gmail.com'); // Gets the ID of the calendar and logs it to the console. const calendarId = calendar.getId(); console.log(calendarId);
リターン
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()
カレンダーの名前を取得します。
// Opens the calendar by its ID. // TODO(developer): Replace the ID with your own. const calendar = CalendarApp.getCalendarById('222larabrown@gmail.com'); // Gets the name of the calendar and logs it to the console. // For the default calendar, you can use CalendarApp.getName() instead. const calendarName = calendar.getName(); console.log(calendarName);
リターン
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());
パラメータ
名前 | 型 | 説明 |
---|---|---|
id | String | カレンダー 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 | String | カレンダー名 |
リターン
Calendar[]
- ユーザーが所有するこの名前を持つすべてのカレンダー
認可
このメソッドを使用するスクリプトには、次のスコープのうち 1 つ以上による承認、または関連する REST API からの適切なスコープが必要です。
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
getTimeZone()
カレンダーのタイムゾーンを取得します。
// Opens the calendar by its ID. // TODO(developer): Replace the ID with your own. const calendar = CalendarApp.getCalendarById('222larabrown@gmail.com'); // Gets the time zone of the calendar and logs it to the console. // For the default calendar, you can use CalendarApp.getTimeZone() instead. const timeZone = calendar.getTimeZone(); console.log(timeZone);
リターン
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()
ユーザー インターフェースでカレンダーを非表示にするかどうかを指定します。
// Opens the calendar by its ID. // TODO(developer): Replace the ID with your own. const calendar = CalendarApp.getCalendarById('222larabrown@gmail.com'); // Determines whether the calendar is hidden in the user interface and logs it to the console. // For the default calendar, you can use CalendarApp.isHidden() instead. const isHidden = calendar.isHidden(); console.log(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()
カレンダーを有効なユーザーのメイン カレンダーにするかどうかを決定します。
// Opens the calendar by its ID. // TODO(developer): Replace the ID with your own. const calendar = CalendarApp.getCalendarById('222larabrown@gmail.com'); // Determines whether the calendar is the default calendar for // the effective user and logs it to the console. // For the default calendar, you can use CalendarApp.isMyPrimaryCalendar() instead. const isMyPrimaryCalendar = calendar.isMyPrimaryCalendar(); console.log(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)
カレンダーの色を設定します。
// Opens the calendar by its ID. // TODO(developer): Replace the ID with your own. const calendar = CalendarApp.getCalendarById('222larabrown@gmail.com'); // Sets the color of the calendar to pink using the Calendar Color enum. // For the default calendar, you can use CalendarApp.setColor() instead. calendar.setColor(CalendarApp.Color.PINK);
パラメータ
名前 | 型 | 説明 |
---|---|---|
color | String | CalendarApp.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.')
パラメータ
名前 | 型 | 説明 |
---|---|---|
description | String | このカレンダーの説明 |
リターン
Calendar
- チェーン用のこのカレンダー
認可
このメソッドを使用するスクリプトには、次のスコープのうち 1 つ以上による承認、または関連する REST API からの適切なスコープが必要です。
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
setHidden(hidden)
カレンダーをユーザー インターフェースに表示するかどうかを設定します。
パラメータ
名前 | 型 | 説明 |
---|---|---|
hidden | Boolean | true : ユーザー インターフェースのカレンダーを非表示にします。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 | String | 新しい名前 |
リターン
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);
パラメータ
名前 | 型 | 説明 |
---|---|---|
selected | Boolean | 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');
パラメータ
名前 | 型 | 説明 |
---|---|---|
timeZone | String | 「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());
パラメータ
名前 | 型 | 説明 |
---|---|---|
id | String | 登録するカレンダーの 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());
パラメータ
名前 | 型 | 説明 |
---|---|---|
id | String | 登録するカレンダーの ID。 |
options | Object | 詳細パラメータを指定する JavaScript オブジェクト。下記をご覧ください。 |
拡張パラメータ
名前 | 型 | 説明 |
---|---|---|
color | String | 16 進数の色文字列(「#rrggbb」)または CalendarApp.Colors の値。 |
hidden | Boolean | ユーザー インターフェースでカレンダーを非表示にするかどうか(デフォルト: false )。 |
selected | Boolean | カレンダーの予定をユーザー インターフェースに表示するかどうか(デフォルト: color も指定されている場合は true 、それ以外の場合は false )。 |
リターン
Calendar
- 新しく登録したカレンダー。
例外
Error
- この ID のカレンダーが存在しない場合
認可
このメソッドを使用するスクリプトには、次のスコープのうち 1 つ以上による承認、または関連する REST API からの適切なスコープが必要です。
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds