Class Calendar

カレンダー

ユーザーが所有または登録しているカレンダーを表します。

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新しい終日の予定シリーズを作成します。
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新しいイベント シリーズを作成します。
deleteCalendar()voidカレンダーを完全に削除します。
getColor()Stringカレンダーの色を取得します。
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カレンダーの名前を取得します。
getTimeZone()Stringカレンダーのタイムゾーンを取得します。
isHidden()Booleanユーザー インターフェースでカレンダーを非表示にするかどうかを指定します。
isMyPrimaryCalendar()Booleanカレンダーが有効なユーザーのメイン カレンダーであるかどうかを示します。
isOwnedByMe()Boolean自分がオーナーのカレンダーかどうかを指定します。
isSelected()Booleanカレンダーの予定をユーザー インターフェースに表示するかどうかを指定します。
setColor(color)Calendarカレンダーの色を設定します。
setDescription(description)Calendarカレンダーの説明を設定します。
setHidden(hidden)Calendarカレンダーをユーザー インターフェースに表示するかどうかを設定します。
setName(name)Calendarカレンダーの名前を設定します。
setSelected(selected)Calendarカレンダーの予定をユーザー インターフェースに表示するかどうかを設定します。
setTimeZone(timeZone)Calendarカレンダーのタイムゾーンを設定します。
unsubscribeFromCalendar()voidユーザーのカレンダー登録を解除します。

詳細なドキュメント

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());

パラメータ

名前説明
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());

パラメータ

名前説明
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());

パラメータ

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

拡張パラメータ

名前説明
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());

パラメータ

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

拡張パラメータ

名前説明
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());

パラメータ

名前説明
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());

パラメータ

名前説明
titleString一連のイベントのタイトル
startDateDate一連の最初のイベントの日付(日付のみが使用され、時刻は無視されます)
recurrenceEventRecurrence一連のイベントの繰り返し設定
optionsObject詳細パラメータを指定する JavaScript オブジェクト(下記を参照)

拡張パラメータ

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

リターン

CalendarEventSeries - 作成されたイベント シリーズ

承認

この方法を使用するスクリプトには、次の 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());

パラメータ

名前説明
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());

パラメータ

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

拡張パラメータ

名前説明
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());

パラメータ

名前説明
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());

パラメータ

名前説明
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());

パラメータ

名前説明
titleString一連のイベントのタイトル
startTimeDate一連の最初の予定の開始日時
endTimeDate一連の最初の予定の終了日時
recurrenceEventRecurrence一連のイベントの繰り返し設定
optionsObject詳細パラメータを指定する JavaScript オブジェクト(下記を参照)

拡張パラメータ

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

リターン

CalendarEventSeries - 作成されたイベント シリーズ

承認

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

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

deleteCalendar()

カレンダーを完全に削除します。削除できるのは自分がオーナーのカレンダーのみです。

// Creates a calendar to delete.
const calendar = CalendarApp.createCalendar('Test');

// Deletes the 'Test' calendar permanently.
calendar.deleteCalendar();

例外

Error - インポートされたカレンダーの場合

承認

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

  • https://www.googleapis.com/auth/calendar
  • 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

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 のイベントを取得します。シリーズがデフォルト カレンダー以外のカレンダーに属している場合、このメソッドはそのカレンダーから呼び出す必要があります。CalendarApp.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());

パラメータ

名前説明
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 に対応する場合、一連の中の 1 つのイベントとともに CalendarEventSeries が返されます。一連の予定がデフォルト カレンダー以外のカレンダーに属している場合、このメソッドは Calendar から呼び出す必要があります。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());

パラメータ

名前説明
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);

パラメータ

名前説明
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);

パラメータ

名前説明
startTimeDate期間の開始時
endTimeDate期間の終了日時。
optionsObject詳細パラメータを指定する JavaScript オブジェクト(下記を参照)

拡張パラメータ

名前説明
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);

パラメータ

名前説明
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);

パラメータ

名前説明
dateDateイベントを取得する日付(日付のみが使用され、時間は無視されます)
optionsObject高度なフィルタ オプション

拡張パラメータ

名前説明
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 はメールアドレスです。

// 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

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

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);

パラメータ

名前説明
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.')

パラメータ

名前説明
descriptionStringこのカレンダーの説明

リターン

Calendar - チェーン用のこのカレンダー

承認

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

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

setHidden(hidden)

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

パラメータ

名前説明
hiddenBooleanユーザー インターフェースでカレンダーを非表示にするには 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');

パラメータ

名前説明
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);

パラメータ

名前説明
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');

パラメータ

名前説明
timeZoneString「long」形式で指定されたタイムゾーン(Joda.org でリストされている「America/New_York」など)。

リターン

Calendar - チェーンにするカレンダー。

承認

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

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

unsubscribeFromCalendar()

ユーザーのカレンダー登録を解除します。ユーザーは、[マイカレンダー] リストに表示されているカレンダーを登録解除することはできません。[他のカレンダー] の一覧からカレンダーの登録を解除できます。

// Gets the calendar by its ID.
// TODO(developer): Replace the calendar ID with the calendar ID that you want to get.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Unsubscribes the user from the calendar.
const result = calendar.unsubscribeFromCalendar();

例外

Error - 自分がオーナーのカレンダーの場合

承認

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

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