Class Calendar

ปฏิทิน

แสดงปฏิทินที่ผู้ใช้เป็นเจ้าของหรือติดตามอยู่

เมธอด

วิธีการประเภทการแสดงผลรายละเอียดแบบย่อ
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รับเหตุการณ์ที่มีรหัสที่ระบุ
getEventSeriesById(iCalId)CalendarEventSeriesรับชุดเหตุการณ์ที่มีรหัสที่ระบุ
getEvents(startTime, endTime)CalendarEvent[]รับเหตุการณ์ทั้งหมดที่เกิดขึ้นภายในช่วงวันที่ที่ระบุ
getEvents(startTime, endTime, options)CalendarEvent[]รับเหตุการณ์ทั้งหมดที่เกิดขึ้นภายในช่วงเวลาที่ระบุและตรงกับเกณฑ์ที่ระบุ
getEventsForDay(date)CalendarEvent[]รับเหตุการณ์ทั้งหมดที่เกิดขึ้นในวันหนึ่งๆ
getEventsForDay(date, options)CalendarEvent[]รับเหตุการณ์ทั้งหมดที่เกิดขึ้นในวันหนึ่งๆ และตรงกับเกณฑ์ที่ระบุ
getId()Stringรับรหัสของปฏิทิน
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.
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

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

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 — สตริงสีแบบเลขฐานสิบหก ("#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)

รับเหตุการณ์ที่มีรหัสที่ระบุ หากชุดหนังสือเป็นของปฏิทินอื่นที่ไม่ใช่ปฏิทินเริ่มต้น จะต้องเรียกใช้เมธอดนี้จากปฏิทินนั้น การเรียกใช้ CalendarApp.getEventById(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 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รหัสของเหตุการณ์

รีเทิร์น

CalendarEvent — เหตุการณ์ที่มีรหัสที่ระบุ หรือ 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)

รับชุดเหตุการณ์ที่มีรหัสที่ระบุ หากรหัสที่ระบุเป็นของ CalendarEvent รายการเดียว ระบบจะแสดงผล 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รหัสของชุดกิจกรรม

รีเทิร์น

CalendarEventSeries — ซีรีส์ที่มีรหัสที่ระบุ หรือ 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)

รับเหตุการณ์ทั้งหมดที่เกิดขึ้นภายในช่วงเวลาที่ระบุและตรงกับเกณฑ์ที่ระบุ

เมธอดนี้จะแสดงเหตุการณ์ที่เริ่มต้นในช่วงระยะเวลาที่ระบุ สิ้นสุดในช่วงระยะเวลาที่ระบุ หรือครอบคลุมช่วงระยะเวลาที่ระบุ หากไม่ได้ระบุเขตเวลา ระบบจะตีความค่าเวลาตามบริบทของเขตเวลาของสคริปต์ ซึ่งอาจแตกต่างจากเขตเวลาของปฏิทิน

โปรดทราบว่าการกรองใน author, search หรือ statusFilters จะดำเนินการหลังจากใช้ start และ max ซึ่งหมายความว่าจํานวนเหตุการณ์ที่แสดงอาจน้อยกว่า 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)

รับเหตุการณ์ทั้งหมดที่เกิดขึ้นในวันหนึ่งๆ

เมธอดนี้จะแสดงผลกิจกรรมหากกิจกรรมเริ่มต้นในระหว่างวันที่ที่ระบุ สิ้นสุดในระหว่างวันที่ หรือครอบคลุมทั้งวัน

โปรดทราบว่าระบบจะใช้เฉพาะส่วนของวันที่ในออบเจ็กต์วันที่ และจะไม่สนใจส่วนของเวลา ระบบจะตีความวันที่เป็นเที่ยงคืนของวันนั้นถึงเที่ยงคืนของวันถัดไปในเขตเวลาของปฏิทิน

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

รับเหตุการณ์ทั้งหมดที่เกิดขึ้นในวันหนึ่งๆ และตรงกับเกณฑ์ที่ระบุ

เมธอดนี้จะแสดงผลกิจกรรมหากกิจกรรมเริ่มต้นในระหว่างวันที่ที่ระบุ สิ้นสุดในระหว่างวันที่ หรือครอบคลุมทั้งวัน

โปรดทราบว่าระบบจะใช้เฉพาะส่วนของวันที่ในออบเจ็กต์วันที่ และจะไม่สนใจส่วนของเวลา ระบบจะตีความวันที่เป็นเที่ยงคืนของวันนั้นถึงเที่ยงคืนของวันถัดไปในเขตเวลาของปฏิทิน

โปรดทราบว่าการกรองใน author, search หรือ statusFilters จะดำเนินการหลังจากใช้ start และ max ซึ่งหมายความว่าจํานวนเหตุการณ์ที่แสดงอาจน้อยกว่า 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()

รับรหัสของปฏิทิน รหัสสำหรับปฏิทินเริ่มต้นของผู้ใช้คืออีเมลของผู้ใช้

// 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 — รหัสของปฏิทิน

การให้สิทธิ์

สคริปต์ที่ใช้วิธีการนี้ต้องได้รับอนุญาตด้วยขอบเขตต่อไปนี้อย่างน้อย 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 — เขตเวลาซึ่งระบุในรูปแบบ "แบบยาว" (เช่น "อเมริกา/นิวยอร์ก" ตามที่ระบุโดย Joda.org)

การให้สิทธิ์

สคริปต์ที่ใช้วิธีการนี้ต้องได้รับอนุญาตด้วยขอบเขตต่อไปนี้อย่างน้อย 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);

รีเทิร์น

Booleantrue หากปฏิทินซ่อนอยู่ในอินเทอร์เฟซผู้ใช้ 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);

รีเทิร์น

Booleantrue หากปฏิทินเป็นปฏิทินเริ่มต้นของผู้ใช้ที่มีสิทธิ์ 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());

รีเทิร์น

Booleantrue หากคุณเป็นเจ้าของปฏิทิน หรือ 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());

รีเทิร์น

Booleantrue หากกิจกรรมของปฏิทินแสดงในอินเทอร์เฟซผู้ใช้ 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 หรือสตริงสีแบบเลขฐานสิบหก ("#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เขตเวลาซึ่งระบุในรูปแบบ "แบบยาว" (เช่น "อเมริกา/นิวยอร์ก" ตามรายชื่อของ Joda.org)

รีเทิร์น

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