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.
var event = CalendarApp.getDefaultCalendar().createAllDayEvent('Apollo 11 Landing',
    new Date('July 20, 1969'));
Logger.log('Event ID: ' + event.getId());

พารามิเตอร์

ชื่อTypeคำอธิบาย
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());

พารามิเตอร์

ชื่อTypeคำอธิบาย
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());

พารามิเตอร์

ชื่อTypeคำอธิบาย
titleStringชื่อกิจกรรม
startDateDateวันที่ที่กิจกรรมเริ่มต้น (ใช้เฉพาะวัน โดยไม่สนใจเวลา)
endDateDateวันที่ที่กิจกรรมสิ้นสุดลง (ใช้เฉพาะวัน โดยไม่สนใจเวลา) วันที่สิ้นสุดจะไม่รวมอยู่ด้วย
optionsObjectออบเจ็กต์ JavaScript ที่ระบุพารามิเตอร์ขั้นสูงดังที่แสดงด้านล่าง

พารามิเตอร์ขั้นสูง

ชื่อTypeคำอธิบาย
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());

พารามิเตอร์

ชื่อTypeคำอธิบาย
titleStringชื่อกิจกรรม
dateDateวันที่เกิดเหตุการณ์ (ใช้เฉพาะวัน โดยไม่สนใจเวลา)
optionsObjectออบเจ็กต์ JavaScript ที่ระบุพารามิเตอร์ขั้นสูงดังที่แสดงด้านล่าง

พารามิเตอร์ขั้นสูง

ชื่อTypeคำอธิบาย
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());

พารามิเตอร์

ชื่อTypeคำอธิบาย
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());

พารามิเตอร์

ชื่อTypeคำอธิบาย
titleStringชื่อกิจกรรมในชุด
startDateDateวันที่ของกิจกรรมแรกของชุดนี้ (ใช้เฉพาะวัน โดยระบบจะไม่สนใจเวลา)
recurrenceEventRecurrenceการตั้งค่าการเกิดซ้ำของชุดกิจกรรม
optionsObjectออบเจ็กต์ JavaScript ที่ระบุพารามิเตอร์ขั้นสูง ดังที่แสดงด้านล่าง

พารามิเตอร์ขั้นสูง

ชื่อTypeคำอธิบาย
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());

พารามิเตอร์

ชื่อTypeคำอธิบาย
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());

พารามิเตอร์

ชื่อTypeคำอธิบาย
titleStringชื่อกิจกรรม
startTimeDateวันที่และเวลาที่กิจกรรมเริ่มต้น
endTimeDateวันที่และเวลาที่กิจกรรมสิ้นสุดลง
optionsObjectออบเจ็กต์ JavaScript ที่ระบุพารามิเตอร์ขั้นสูง ดังที่แสดงด้านล่าง

พารามิเตอร์ขั้นสูง

ชื่อTypeคำอธิบาย
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());

พารามิเตอร์

ชื่อTypeคำอธิบาย
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());

พารามิเตอร์

ชื่อTypeคำอธิบาย
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());

พารามิเตอร์

ชื่อTypeคำอธิบาย
titleStringชื่อกิจกรรมในชุด
startTimeDateวันที่และเวลาที่กิจกรรมแรกในชุดเริ่มต้น
endTimeDateวันที่และเวลาที่กิจกรรมแรกของชุดกิจกรรมสิ้นสุดลง
recurrenceEventRecurrenceการตั้งค่าการเกิดซ้ำของชุดกิจกรรม
optionsObjectออบเจ็กต์ JavaScript ที่ระบุพารามิเตอร์ขั้นสูง ดังที่แสดงด้านล่าง

พารามิเตอร์ขั้นสูง

ชื่อTypeคำอธิบาย
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)

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

พารามิเตอร์

ชื่อTypeคำอธิบาย
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());

พารามิเตอร์

ชื่อTypeคำอธิบาย
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.
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);

พารามิเตอร์

ชื่อTypeคำอธิบาย
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".
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);

พารามิเตอร์

ชื่อTypeคำอธิบาย
startTimeDateจุดเริ่มต้นของช่วงเวลา
endTimeDateจุดสิ้นสุดของช่วงเวลา โดยไม่รวม
optionsObjectออบเจ็กต์ JavaScript ที่ระบุพารามิเตอร์ขั้นสูง ดังที่แสดงด้านล่าง

พารามิเตอร์ขั้นสูง

ชื่อTypeคำอธิบาย
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.
var today = new Date();
var events = CalendarApp.getDefaultCalendar().getEventsForDay(today);
Logger.log('Number of events: ' + events.length);

พารามิเตอร์

ชื่อTypeคำอธิบาย
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".
var today = new Date();
var events = CalendarApp.getDefaultCalendar().getEventsForDay(today, {search: 'meeting'});
Logger.log('Number of events: ' + events.length);

พารามิเตอร์

ชื่อTypeคำอธิบาย
dateDateวันที่ที่จะเรียกดูเหตุการณ์ (ใช้เฉพาะวัน เวลาจะถูกละเว้น)
optionsObjectตัวเลือกการกรองขั้นสูง

พารามิเตอร์ขั้นสูง

ชื่อTypeคำอธิบาย
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 — เขตเวลาที่ระบุในรูปแบบ "long" (เช่น "America/New_York" ตามที่แสดงใน 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);

พารามิเตอร์

ชื่อTypeคำอธิบาย
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.')

พารามิเตอร์

ชื่อTypeคำอธิบาย
descriptionStringคำอธิบายของปฏิทินนี้

รีเทิร์น

Calendar — ปฏิทินนี้สำหรับการทำเชน

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

สคริปต์ที่ใช้วิธีนี้จะต้องมีการให้สิทธิ์กับขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง

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

setHidden(hidden)

ตั้งค่าว่าจะให้ปฏิทินปรากฏในอินเทอร์เฟซผู้ใช้หรือไม่

พารามิเตอร์

ชื่อTypeคำอธิบาย
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');

พารามิเตอร์

ชื่อTypeคำอธิบาย
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);

พารามิเตอร์

ชื่อTypeคำอธิบาย
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');

พารามิเตอร์

ชื่อTypeคำอธิบาย
timeZoneStringเขตเวลาที่ระบุในรูปแบบ "long" (เช่น "America/New_York" ตามที่แสดงใน 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