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)

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

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

โปรดทราบว่าระบบจะใช้เฉพาะส่วนวันที่ของออบเจ็กต์ 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)

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

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

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

โปรดทราบว่าการกรองใน 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 — เขตเวลาที่ระบุในรูปแบบ "ยาว" (เช่น "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);

พารามิเตอร์

ชื่อประเภทคำอธิบาย
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เขตเวลาที่ระบุในรูปแบบ "ยาว" (เช่น "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