Class CalendarApp

カレンダーアプリ

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

プロパティ

プロパティタイプ説明
ColorColorカレンダー サービスで使用できる名前付きの色を表す列挙型。
EventColorEventColorカレンダー サービスで使用できる名前付きの予定の色を表す列挙型。
EventTransparencyEventTransparencyEventTransparency 列挙型。
EventTypeEventTypeEventType 列挙型。
GuestStatusGuestStatus予定に対するゲストのステータスを表す列挙型。
MonthMonth1 年の月を表す列挙型。
VisibilityVisibilityイベントの公開設定を表す列挙型。
WeekdayWeekday曜日を表す列挙型。

メソッド

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

詳細なドキュメント

createAllDayEvent(title, date)

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

// Creates an all-day event for the moon landing and logs the ID.
const 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.
const 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.
const 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.
const 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.
const 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.
const 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

createCalendar(name)

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

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

パラメータ

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

戻る

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

承認

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

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

createCalendar(name, options)

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

// Creates a new calendar named "Travel Plans" with a description and color.
const calendar = CalendarApp.createCalendar('Travel Plans', {
  description: '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(),
);

パラメータ

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

高度なパラメータ

名前説明
locationStringカレンダーの場所
descriptionStringカレンダーの説明
timeZoneStringカレンダーを設定するタイムゾーン。long 形式で指定します(例: (Joda.org に記載されているとおり)
colorString16 進数カラー文字列(「#rrggbb」)または CalendarApp.Colors の値
hiddenBooleanカレンダーがユーザー インターフェースで非表示になっているかどうか(デフォルト: false
selectedBooleanカレンダーの予定をユーザー インターフェースに表示するかどうか(デフォルト: true

戻る

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

承認

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

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

createEvent(title, startTime, endTime)

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

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

// Creates an event for the moon landing and logs the ID.
const 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.
const 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.
const 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.
const 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.
const 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

getAllCalendars()

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

// Determines how many calendars the user can access.
const 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.
const 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.
const calendar = CalendarApp.getCalendarById(
    'en.usa#holiday@group.v.calendar.google.com',
);
Logger.log('The calendar is named "%s".', calendar.getName());

パラメータ

名前説明
idStringカレンダー ID

戻る

Calendar|null - 指定された 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".
const calendars = CalendarApp.getCalendarsByName('US Holidays');
Logger.log('Found %s matching calendars.', calendars.length);

パラメータ

名前説明
nameStringカレンダー名

戻る

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

承認

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

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

getColor()

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

// 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.
const 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());

パラメータ

名前説明
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 が 1 つの 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());

パラメータ

名前説明
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.
const now = new Date();
const twoHoursFromNow = new Date(now.getTime() + 2 * 60 * 60 * 1000);
const 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".
const now = new Date();
const twoHoursFromNow = new Date(now.getTime() + 2 * 60 * 60 * 1000);
const 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.
const today = new Date();
const 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".
const today = new Date();
const 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

getOwnedCalendarById(id)

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

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

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

パラメータ

名前説明
idStringカレンダー ID

戻る

Calendar|null - 指定された 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".
const calendars = CalendarApp.getOwnedCalendarsByName('Travel Plans');
Logger.log('Found %s matching calendars.', calendars.length);

パラメータ

名前説明
nameStringカレンダー名

戻る

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

承認

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

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

getTimeZone()

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

// 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 - タイムゾーン。Joda.org に記載されているように、「long」形式で指定します(例: 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.
const recurrence = CalendarApp.newRecurrence()
                       .addWeeklyRule()
                       .onlyOnWeekday(CalendarApp.Weekday.WEDNESDAY)
                       .until(new Date('January 1, 2014'));
const 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);

パラメータ

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

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

パラメータ

名前説明
hiddenBooleantrue: ユーザー インターフェースでカレンダーを非表示にする。false: カレンダーを表示する。

戻る

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

承認

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

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

setName(name)

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

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

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

パラメータ

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

パラメータ

名前説明
selectedBooleantrue: カレンダーの予定をユーザー インターフェースに表示します。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

subscribeToCalendar(id)

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

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

パラメータ

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

戻る

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

例外

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

承認

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

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

subscribeToCalendar(id, options)

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

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

パラメータ

名前説明
idString登録するカレンダーの ID。
optionsObject以下に示す高度なパラメータを指定する JavaScript オブジェクト。

高度なパラメータ

名前説明
colorString16 進数の色文字列(「#rrggbb」)または CalendarApp.Colors の値。
hiddenBooleanカレンダーがユーザー インターフェースで非表示になっているかどうか(デフォルト: false)。
selectedBooleanカレンダーの予定をユーザー インターフェースに表示するかどうか(デフォルト: color も指定されている場合は true、それ以外の場合は false)。

戻る

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

例外

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

承認

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

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