ユーザーの Google カレンダーの読み取りと更新をスクリプトに許可します。このクラスは、ユーザーのデフォルト カレンダーへの直接アクセスと、ユーザーが所有または登録した追加のカレンダーの取得機能を提供します。
プロパティ
プロパティ | タイプ | 説明 |
---|---|---|
Color | Color | カレンダー サービスで利用可能な名前付きの色を表す列挙型。 |
EventColor | EventColor | カレンダー サービスで利用可能な名前付き予定の色を表す列挙型。 |
GuestStatus | GuestStatus | ゲストがイベントに対して行えるステータスを表す列挙型。 |
Month | Month | 月を表す列挙型。 |
Visibility | Visibility | イベントの公開設定を表す列挙型。 |
Weekday | Weekday | 曜日を表す列挙型。 |
Methods
詳細なドキュメント
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 | 型 | 説明 |
---|---|---|
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());
パラメータ
Name | 型 | 説明 |
---|---|---|
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());
パラメータ
Name | 型 | 説明 |
---|---|---|
title | String | イベントのタイトル。 |
startDate | Date | イベントの開始日(時間のみが使用されます。時間は無視されます)。 |
endDate | Date | イベントの終了日(時刻のみが使用されます。時刻は無視されます)。終了日は含まれません。 |
options | Object | 下記の詳細なパラメータを指定する JavaScript オブジェクト。 |
拡張パラメータ
Name | 型 | 説明 |
---|---|---|
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());
パラメータ
Name | 型 | 説明 |
---|---|---|
title | String | イベントのタイトル。 |
date | Date | 予定の日付(日のみを使用し、時刻は無視されます)。 |
options | Object | 下記の詳細なパラメータを指定する JavaScript オブジェクト。 |
拡張パラメータ
Name | 型 | 説明 |
---|---|---|
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());
パラメータ
Name | 型 | 説明 |
---|---|---|
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());
パラメータ
Name | 型 | 説明 |
---|---|---|
title | String | 一連のイベントのタイトル |
startDate | Date | 一連の最初のイベントの日付(時間のみが使用され、時間は無視されます) |
recurrence | EventRecurrence | 一連の定期的な予定の設定 |
options | Object | 高度なパラメータを指定する JavaScript オブジェクト(下記参照) |
拡張パラメータ
Name | 型 | 説明 |
---|---|---|
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 | 型 | 説明 |
---|---|---|
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 | 型 | 説明 |
---|---|---|
name | String | 新しいカレンダーの名前 |
options | Object | 高度なパラメータを指定する JavaScript オブジェクト(下記参照) |
拡張パラメータ
Name | 型 | 説明 |
---|---|---|
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());
パラメータ
Name | 型 | 説明 |
---|---|---|
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());
パラメータ
Name | 型 | 説明 |
---|---|---|
title | String | イベントのタイトル |
startTime | Date | イベントの開始日時 |
endTime | Date | 予定の終了日時 |
options | Object | 高度なパラメータを指定する JavaScript オブジェクト(下記参照) |
拡張パラメータ
Name | 型 | 説明 |
---|---|---|
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());
パラメータ
Name | 型 | 説明 |
---|---|---|
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());
パラメータ
Name | 型 | 説明 |
---|---|---|
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());
パラメータ
Name | 型 | 説明 |
---|---|---|
title | String | 一連のイベントのタイトル |
startTime | Date | 一連の定期的な予定の開始日時 |
endTime | Date | 一連の予定の最初のイベントが終了する日時 |
recurrence | EventRecurrence | 一連の定期的な予定の設定 |
options | Object | 高度なパラメータを指定する JavaScript オブジェクト(下記参照) |
拡張パラメータ
Name | 型 | 説明 |
---|---|---|
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());
パラメータ
Name | 型 | 説明 |
---|---|---|
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 | 型 | 説明 |
---|---|---|
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()
カレンダーの色を取得します。
復路
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 | 型 | 説明 |
---|---|---|
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
に対するものである場合、一連の単一のイベントに対して CalendarEventSeries
が返されます。イベント シリーズがデフォルト カレンダー以外のカレンダーに属している場合、このメソッドはその CalendarApp
から呼び出す必要があります。getEventSeriesById(iCalId)
を直接呼び出すと、デフォルト カレンダー内に存在するイベント シリーズのみが返されます。
パラメータ
Name | 型 | 説明 |
---|---|---|
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);
パラメータ
Name | 型 | 説明 |
---|---|---|
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);
パラメータ
Name | 型 | 説明 |
---|---|---|
startTime | Date | 期間の開始 |
endTime | Date | 期間の終了時(指定不可) |
options | Object | 高度なパラメータを指定する JavaScript オブジェクト(下記参照) |
拡張パラメータ
Name | 型 | 説明 |
---|---|---|
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);
パラメータ
Name | 型 | 説明 |
---|---|---|
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);
パラメータ
Name | 型 | 説明 |
---|---|---|
date | Date | 予定を取得する日付です(日付のみが使用されます。時間は無視されます)。 |
options | Object | 高度なフィルタ オプション |
拡張パラメータ
Name | 型 | 説明 |
---|---|---|
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 はユーザーのメールアドレスです。
復路
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 | 型 | 説明 |
---|---|---|
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 | 型 | 説明 |
---|---|---|
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()
カレンダーのタイムゾーンを取得します。
復路
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 | 型 | 説明 |
---|---|---|
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.')
パラメータ
Name | 型 | 説明 |
---|---|---|
description | String | このカレンダーの説明 |
復路
Calendar
- 連結用のカレンダー
認証
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
setHidden(hidden)
カレンダーをユーザー インターフェースに表示するかどうかを設定します。
パラメータ
Name | 型 | 説明 |
---|---|---|
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 | 型 | 説明 |
---|---|---|
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);
パラメータ
Name | 型 | 説明 |
---|---|---|
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');
パラメータ
Name | 型 | 説明 |
---|---|---|
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());
パラメータ
Name | 型 | 説明 |
---|---|---|
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());
パラメータ
Name | 型 | 説明 |
---|---|---|
id | String | 登録するカレンダーの ID |
options | Object | 高度なパラメータを指定する JavaScript オブジェクト(下記参照) |
拡張パラメータ
Name | 型 | 説明 |
---|---|---|
color | String | 16 進数のカラー文字列(「#rrggbb」)、または CalendarApp.Colors の値 |
hidden | Boolean | ユーザー インターフェースでカレンダーを非表示にするかどうか(デフォルト: false )。 |
selected | Boolean | カレンダーの予定をユーザー インターフェースに表示するかどうか(デフォルト: true )。 |
復路
Calendar
- 新しく登録したカレンダー
例外
Error
- この ID を持つカレンダーが存在しない場合
認証
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープまたは関連する REST API からの適切なスコープによる承認が必要です。
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds