อนุญาตให้สคริปต์อ่านและอัปเดต Google ปฏิทินของผู้ใช้ คลาสนี้ให้สิทธิ์เข้าถึงโดยตรง ไปยังปฏิทินเริ่มต้นของผู้ใช้ รวมถึงความสามารถในการเรียกปฏิทินเพิ่มเติมที่ ผู้ใช้เป็นเจ้าของหรือติดตามอยู่
พร็อพเพอร์ตี้
| พร็อพเพอร์ตี้ | ประเภท | คำอธิบาย |
|---|---|---|
Color | Color | การแจงนับที่แสดงสีที่มีชื่อซึ่งพร้อมใช้งานในบริการปฏิทิน |
Event | Event | การแจงนับที่แสดงสีของกิจกรรมที่มีชื่อซึ่งพร้อมใช้งานในบริการปฏิทิน |
Event | Event | Eventการแจงนับ |
Event | Event | Eventการแจงนับ |
Guest | Guest | การแจงนับที่แสดงสถานะที่ผู้เข้าร่วมมีได้สำหรับกิจกรรม |
Month | Month | การแจงนับที่แสดงเดือนของปี |
Visibility | Visibility | การแจงนับที่แสดงถึงระดับการเข้าถึงของกิจกรรม |
Weekday | Weekday | การแจงนับที่แสดงวันในสัปดาห์ |
เมธอด
| วิธีการ | ประเภทการแสดงผล | รายละเอียดแบบย่อ |
|---|---|---|
create | Calendar | สร้างกิจกรรมใหม่ที่เกิดขึ้นตลอดวัน |
create | Calendar | สร้างกิจกรรมใหม่ที่เกิดขึ้นตลอดทั้งวันซึ่งอาจกินเวลาหลายวัน |
create | Calendar | สร้างกิจกรรมใหม่ที่เกิดขึ้นตลอดทั้งวันซึ่งอาจกินเวลาหลายวัน |
create | Calendar | สร้างกิจกรรมใหม่ที่เกิดขึ้นตลอดวัน |
create | Calendar | สร้างชุดกิจกรรมใหม่ที่เกิดขึ้นตลอดวัน |
create | Calendar | สร้างชุดกิจกรรมใหม่ที่เกิดขึ้นตลอดวัน |
create | Calendar | สร้างปฏิทินใหม่ที่ผู้ใช้เป็นเจ้าของ |
create | Calendar | สร้างปฏิทินใหม่ที่ผู้ใช้เป็นเจ้าของ |
create | Calendar | สร้างกิจกรรมใหม่ |
create | Calendar | สร้างกิจกรรมใหม่ |
create | Calendar | สร้างกิจกรรมจากคำอธิบายรูปแบบอิสระ |
create | Calendar | สร้างซีรีส์กิจกรรมใหม่ |
create | Calendar | สร้างซีรีส์กิจกรรมใหม่ |
get | Calendar[] | รับปฏิทินทั้งหมดที่ผู้ใช้เป็นเจ้าของหรือติดตาม |
get | Calendar[] | รับปฏิทินทั้งหมดที่ผู้ใช้เป็นเจ้าของ |
get | Calendar|null | รับปฏิทินที่มีรหัสที่ระบุ |
get | Calendar[] | รับปฏิทินทั้งหมดที่มีชื่อที่ระบุซึ่งผู้ใช้เป็นเจ้าของหรือติดตาม |
get | String | รับสีของปฏิทิน |
get | Calendar | รับปฏิทินเริ่มต้นของผู้ใช้ |
get | String | รับคำอธิบายของปฏิทิน |
get | Calendar | รับกิจกรรมที่มีรหัสที่ระบุ |
get | Calendar | รับชุดกิจกรรมที่มีรหัสที่ระบุ |
get | Calendar | รับเหตุการณ์ทั้งหมดที่เกิดขึ้นภายในช่วงเวลาที่กำหนด |
get | Calendar | รับเหตุการณ์ทั้งหมดที่เกิดขึ้นภายในช่วงเวลาที่กำหนดและเป็นไปตามเกณฑ์ที่ระบุ |
get | Calendar | รับเหตุการณ์ทั้งหมดที่เกิดขึ้นในวันหนึ่งๆ |
get | Calendar | รับเหตุการณ์ทั้งหมดที่เกิดขึ้นในวันที่ระบุและตรงตามเกณฑ์ที่ระบุ |
get | String | รับรหัสของปฏิทิน |
get | String | รับชื่อปฏิทิน |
get | Calendar|null | รับปฏิทินที่มีรหัสที่ระบุ หากผู้ใช้เป็นเจ้าของ |
get | Calendar[] | รับปฏิทินทั้งหมดที่มีชื่อที่ระบุซึ่งผู้ใช้เป็นเจ้าของ |
get | String | รับเขตเวลาของปฏิทิน |
is | Boolean | กำหนดว่าจะซ่อนปฏิทินในอินเทอร์เฟซผู้ใช้หรือไม่ |
is | Boolean | กำหนดว่าปฏิทินเป็นปฏิทินหลักสำหรับผู้ใช้ที่มีผลหรือไม่ |
is | Boolean | ระบุว่าคุณเป็นเจ้าของปฏิทินหรือไม่ |
is | Boolean | กำหนดว่าจะแสดงกิจกรรมของปฏิทินในอินเทอร์เฟซผู้ใช้หรือไม่ |
new | Event | สร้างออบเจ็กต์การเกิดซ้ำใหม่ ซึ่งใช้สร้างกฎสำหรับการเกิดซ้ำของเหตุการณ์ได้ |
set | Calendar | ตั้งค่าสีของปฏิทิน |
set | Calendar | ตั้งค่าคำอธิบายของปฏิทิน |
set | Calendar | กำหนดว่าจะให้ปฏิทินปรากฏในอินเทอร์เฟซผู้ใช้หรือไม่ |
set | Calendar | ตั้งชื่อปฏิทิน |
set | Calendar | กำหนดว่าจะแสดงกิจกรรมของปฏิทินในอินเทอร์เฟซผู้ใช้หรือไม่ |
set | Calendar | ตั้งค่าเขตเวลาของปฏิทิน |
subscribe | Calendar | ติดตามปฏิทินของผู้ใช้ด้วยรหัสที่ระบุ หากผู้ใช้ได้รับอนุญาตให้ติดตาม |
subscribe | Calendar | ติดตามปฏิทินของผู้ใช้ด้วยรหัสที่ระบุ หากผู้ใช้ได้รับอนุญาตให้ติดตาม |
เอกสารโดยละเอียด
create All Day Event(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()}`);
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
title | String | ชื่อกิจกรรม |
date | Date | วันที่ของกิจกรรม (ใช้เฉพาะวัน ส่วนเวลาจะถูกละเว้น) |
รีเทิร์น
Calendar — กิจกรรมที่สร้างขึ้น
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.google.com/calendar/feeds
create All Day Event(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()}`);
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
title | String | ชื่อกิจกรรม |
start | Date | วันที่กิจกรรมเริ่มต้น (ใช้เฉพาะวัน ส่วนระบบจะไม่สนใจเวลา) |
end | Date | วันที่กิจกรรมสิ้นสุด (ใช้เฉพาะวัน ไม่สนใจเวลา) โดย วันที่สิ้นสุดจะไม่รวมอยู่ในช่วง |
รีเทิร์น
Calendar — กิจกรรมที่สร้างขึ้น
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.google.com/calendar/feeds
create All Day Event(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()}`);
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
title | String | ชื่อกิจกรรม |
start | Date | วันที่กิจกรรมเริ่มต้น (ใช้เฉพาะวัน ส่วนระบบจะไม่สนใจเวลา) |
end | Date | วันที่กิจกรรมสิ้นสุด (ใช้เฉพาะวัน ไม่สนใจเวลา) โดย วันที่สิ้นสุดจะไม่รวมอยู่ในช่วง |
options | Object | ออบเจ็กต์ JavaScript ที่ระบุพารามิเตอร์ขั้นสูงตามที่ระบุไว้ด้านล่าง |
พารามิเตอร์ขั้นสูง
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
description | String | คำอธิบายของกิจกรรม |
location | String | สถานที่จัดกิจกรรม |
guests | String | รายชื่ออีเมลที่คั่นด้วยคอมมาซึ่งควรเพิ่ม เป็นผู้เข้าร่วม |
send | Boolean | จะส่งอีเมลคำเชิญหรือไม่ (ค่าเริ่มต้น: false) |
รีเทิร์น
Calendar — กิจกรรมที่สร้างขึ้น
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.google.com/calendar/feeds
create All Day Event(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()}`);
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
title | String | ชื่อกิจกรรม |
date | Date | วันที่ของกิจกรรม (ใช้เฉพาะวัน ส่วนเวลาจะถูกละเว้น) |
options | Object | ออบเจ็กต์ JavaScript ที่ระบุพารามิเตอร์ขั้นสูงตามที่ระบุไว้ด้านล่าง |
พารามิเตอร์ขั้นสูง
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
description | String | คำอธิบายของกิจกรรม |
location | String | สถานที่จัดกิจกรรม |
guests | String | รายชื่ออีเมลที่คั่นด้วยคอมมาซึ่งควรเพิ่ม เป็นผู้เข้าร่วม |
send | Boolean | จะส่งอีเมลคำเชิญหรือไม่ (ค่าเริ่มต้น: false) |
รีเทิร์น
Calendar — กิจกรรมที่สร้างขึ้น
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.google.com/calendar/feeds
create All Day Event Series(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()}`);
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
title | String | ชื่อของกิจกรรมในชุด |
start | Date | วันที่ของเหตุการณ์แรกในชุด (ใช้เฉพาะวัน เวลาจะถูก ละเว้น) |
recurrence | Event | การตั้งค่าการเกิดซ้ำของชุดกิจกรรม |
รีเทิร์น
Calendar - กิจกรรมที่สร้างขึ้น
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.google.com/calendar/feeds
create All Day Event Series(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()}`);
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
title | String | ชื่อของกิจกรรมในชุด |
start | Date | วันที่ของเหตุการณ์แรกในชุด (ใช้เฉพาะวัน เวลาจะถูก ละเว้น) |
recurrence | Event | การตั้งค่าการเกิดซ้ำของชุดกิจกรรม |
options | Object | ออบเจ็กต์ JavaScript ที่ระบุพารามิเตอร์ขั้นสูงตามที่ระบุไว้ด้านล่าง |
พารามิเตอร์ขั้นสูง
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
description | String | คำอธิบายกิจกรรมในชุด |
location | String | สถานที่จัดกิจกรรมในชุด |
guests | String | รายชื่ออีเมลที่คั่นด้วยคอมมาซึ่งควรเพิ่ม เป็นผู้เข้าร่วมในกิจกรรมในชุด |
send | Boolean | ว่าจะส่งอีเมลคำเชิญหรือไม่ (ค่าเริ่มต้น: false) |
รีเทิร์น
Calendar - กิจกรรมที่สร้างขึ้น
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.google.com/calendar/feeds
create Calendar(name)
สร้างปฏิทินใหม่ที่ผู้ใช้เป็นเจ้าของ
// Creates a new calendar named "Travel Plans". const calendar = CalendarApp.createCalendar('Travel Plans'); Logger.log( 'Created the calendar "%s", with the ID "%s".', calendar.getName(), calendar.getId(), );
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
name | String | ชื่อของปฏิทินใหม่ |
รีเทิร์น
Calendar - ปฏิทินที่สร้างขึ้นใหม่
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.google.com/calendar/feeds
create Calendar(name, options)
สร้างปฏิทินใหม่ที่ผู้ใช้เป็นเจ้าของ
// Creates a new calendar named "Travel Plans" with a description and color. const calendar = CalendarApp.createCalendar('Travel Plans', { description: 'A calendar to plan my travel schedule.', color: CalendarApp.Color.BLUE, }); Logger.log( 'Created the calendar "%s", with the ID "%s".', calendar.getName(), calendar.getId(), );
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
name | String | ชื่อของปฏิทินใหม่ |
options | Object | ออบเจ็กต์ JavaScript ที่ระบุพารามิเตอร์ขั้นสูงตามที่ระบุไว้ด้านล่าง |
พารามิเตอร์ขั้นสูง
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
location | String | ตำแหน่งของปฏิทิน |
description | String | คำอธิบายของปฏิทิน |
time | String | เขตเวลาที่จะตั้งค่าปฏิทิน ซึ่งระบุในรูปแบบ "ยาว" (เช่น "America/New_York" ตามที่ระบุไว้ใน Joda.org) |
color | String | สตริงสีแบบเลขฐานสิบหก ("#rrggbb") หรือค่าจาก Calendar |
hidden | Boolean | ไม่ว่าจะซ่อนปฏิทินในอินเทอร์เฟซผู้ใช้หรือไม่ (ค่าเริ่มต้น:
false) |
selected | Boolean | ว่าจะแสดงกิจกรรมของปฏิทินในอินเทอร์เฟซผู้ใช้หรือไม่ (ค่าเริ่มต้น: true) |
รีเทิร์น
Calendar - ปฏิทินที่สร้างขึ้นใหม่
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.google.com/calendar/feeds
create Event(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()}`);
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
title | String | ชื่อกิจกรรม |
start | Date | วันที่และเวลาที่กิจกรรมเริ่ม |
end | Date | วันที่และเวลาที่กิจกรรมสิ้นสุด |
รีเทิร์น
Calendar - กิจกรรมที่สร้างขึ้น
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.google.com/calendar/feeds
create Event(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()}`);
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
title | String | ชื่อกิจกรรม |
start | Date | วันที่และเวลาที่กิจกรรมเริ่ม |
end | Date | วันที่และเวลาที่กิจกรรมสิ้นสุด |
options | Object | ออบเจ็กต์ JavaScript ที่ระบุพารามิเตอร์ขั้นสูงตามที่ระบุไว้ด้านล่าง |
พารามิเตอร์ขั้นสูง
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
description | String | คำอธิบายกิจกรรม |
location | String | สถานที่จัดกิจกรรม |
guests | String | รายชื่ออีเมลที่คั่นด้วยคอมมาซึ่งควรเพิ่ม เป็นแขกรับเชิญ |
send | Boolean | ว่าจะส่งอีเมลคำเชิญหรือไม่ (ค่าเริ่มต้น: false) |
รีเทิร์น
Calendar - กิจกรรมที่สร้างขึ้น
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.google.com/calendar/feeds
create Event From Description(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()}`);
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
description | String | คำอธิบายเหตุการณ์แบบอิสระ |
รีเทิร์น
Calendar - กิจกรรมที่สร้างขึ้น
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.google.com/calendar/feeds
create Event Series(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()}`);
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
title | String | ชื่อของกิจกรรมในชุด |
start | Date | วันที่และเวลาที่กิจกรรมแรกในชุดเริ่มต้น |
end | Date | วันที่และเวลาที่เหตุการณ์แรกในชุดสิ้นสุด |
recurrence | Event | การตั้งค่าการเกิดซ้ำของชุดกิจกรรม |
รีเทิร์น
Calendar - กิจกรรมที่สร้างขึ้น
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.google.com/calendar/feeds
create Event Series(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()}`);
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
title | String | ชื่อของกิจกรรมในชุด |
start | Date | วันที่และเวลาที่กิจกรรมแรกในชุดเริ่มต้น |
end | Date | วันที่และเวลาที่เหตุการณ์แรกในชุดสิ้นสุด |
recurrence | Event | การตั้งค่าการเกิดซ้ำของชุดกิจกรรม |
options | Object | ออบเจ็กต์ JavaScript ที่ระบุพารามิเตอร์ขั้นสูงตามที่ระบุไว้ด้านล่าง |
พารามิเตอร์ขั้นสูง
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
description | String | คำอธิบายกิจกรรมในชุด |
location | String | สถานที่จัดกิจกรรมในชุด |
guests | String | รายชื่ออีเมลที่คั่นด้วยคอมมาซึ่งควรเพิ่ม เป็นผู้เข้าร่วมในกิจกรรมในชุด |
send | Boolean | ว่าจะส่งอีเมลคำเชิญหรือไม่ (ค่าเริ่มต้น: false) |
รีเทิร์น
Calendar - กิจกรรมที่สร้างขึ้น
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.google.com/calendar/feeds
get All Calendars()
รับปฏิทินทั้งหมดที่ผู้ใช้เป็นเจ้าของหรือติดตาม
// Determines how many calendars the user can access. const calendars = CalendarApp.getAllCalendars(); Logger.log( 'This user owns or is subscribed to %s calendars.', calendars.length, );
รีเทิร์น
Calendar[] - ปฏิทินทั้งหมดที่ผู้ใช้เข้าถึงได้
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.googleapis.com/auth/calendar.readonly -
https://www.google.com/calendar/feeds
get All Owned Calendars()
รับปฏิทินทั้งหมดที่ผู้ใช้เป็นเจ้าของ
// Determines how many calendars the user owns. const calendars = CalendarApp.getAllOwnedCalendars(); Logger.log('This user owns %s calendars.', calendars.length);
รีเทิร์น
Calendar[] - ปฏิทินทั้งหมดที่ผู้ใช้เป็นเจ้าของ
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.googleapis.com/auth/calendar.readonly -
https://www.google.com/calendar/feeds
get Calendar By Id(id)
รับปฏิทินที่มีรหัสที่ระบุ
// Gets the public calendar "US Holidays" by ID. const calendar = CalendarApp.getCalendarById( 'en.usa#holiday@group.v.calendar.google.com', ); Logger.log('The calendar is named "%s".', calendar.getName());
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
id | String | รหัสปฏิทิน |
รีเทิร์น
Calendar|null — ปฏิทินที่มีรหัสที่ระบุ หรือ null หากไม่มีปฏิทินดังกล่าว หากผู้ใช้เข้าถึงไม่ได้ หรือหากผู้ใช้ไม่ได้ติดตามปฏิทิน
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.googleapis.com/auth/calendar.readonly -
https://www.google.com/calendar/feeds
get Calendars By Name(name)
รับปฏิทินทั้งหมดที่มีชื่อที่ระบุซึ่งผู้ใช้เป็นเจ้าของหรือติดตาม ชื่อไม่คำนึงถึงตัวพิมพ์เล็กและตัวพิมพ์ใหญ่
// Gets the public calendar named "US Holidays". const calendars = CalendarApp.getCalendarsByName('US Holidays'); Logger.log('Found %s matching calendars.', calendars.length);
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
name | String | ชื่อปฏิทิน |
รีเทิร์น
Calendar[] - ปฏิทินทั้งหมดที่มีชื่อนี้ซึ่งผู้ใช้เข้าถึงได้
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.googleapis.com/auth/calendar.readonly -
https://www.google.com/calendar/feeds
get Color()
รับสีของปฏิทิน
// 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
get Default Calendar()
รับปฏิทินเริ่มต้นของผู้ใช้
// Determines the time zone of the user's default calendar. const calendar = CalendarApp.getDefaultCalendar(); Logger.log( 'My default calendar is set to the time zone "%s".', calendar.getTimeZone(), );
รีเทิร์น
Calendar - ปฏิทินเริ่มต้นของผู้ใช้
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.googleapis.com/auth/calendar.readonly -
https://www.google.com/calendar/feeds
get Description()
รับคำอธิบายของปฏิทิน
// 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
get Event By Id(iCalId)
รับกิจกรรมที่มีรหัสที่ระบุ หากชุดข้อมูลเป็นของปฏิทินอื่นที่ไม่ใช่ปฏิทินเริ่มต้น
จะต้องเรียกใช้เมธอดนี้จากปฏิทินดังกล่าว การเรียกใช้ get only
จะแสดงกิจกรรมในปฏิทินเริ่มต้น
เหตุการณ์หลายรายการอาจมีรหัสเดียวกันหากเป็นส่วนหนึ่งของชุดเหตุการณ์ ในกรณีนี้ เมธอดนี้จะแสดงเฉพาะเหตุการณ์แรกจากชุดเหตุการณ์นั้น
// 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());
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
iCalId | String | รหัสของเหตุการณ์ |
รีเทิร์น
Calendar — เหตุการณ์ที่มีรหัสที่ระบุ หรือ null หากไม่มีเหตุการณ์หรือผู้ใช้
เข้าถึงไม่ได้
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.googleapis.com/auth/calendar.readonly -
https://www.google.com/calendar/feeds
get Event Series By Id(iCalId)
รับชุดกิจกรรมที่มีรหัสที่ระบุ หากรหัสที่ระบุเป็นของ Calendar รายการเดียว
ระบบจะแสดง Calendar ที่มีกิจกรรมเดียวในชุด โปรดทราบว่าหากชุดกิจกรรมเป็นของปฏิทินอื่นที่ไม่ใช่ปฏิทินเริ่มต้น คุณต้องเรียกใช้เมธอดนี้จาก Calendar นั้น การเรียกใช้ get โดยตรงจะแสดงเฉพาะชุดกิจกรรมที่มีอยู่ในปฏิทินเริ่มต้น
// 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());
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
iCalId | String | รหัสของชุดกิจกรรม |
รีเทิร์น
Calendar — ซีรีส์ที่มีรหัสที่ระบุ หรือ null หากไม่มีซีรีส์หรือผู้ใช้
เข้าถึงไม่ได้
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.googleapis.com/auth/calendar.readonly -
https://www.google.com/calendar/feeds
get Events(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}`);
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
start | Date | จุดเริ่มต้นของช่วงเวลา |
end | Date | จุดสิ้นสุดของช่วงเวลา โดยไม่รวมจุดสิ้นสุด |
รีเทิร์น
Calendar — เหตุการณ์ที่เกิดขึ้นภายในช่วงเวลา
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.googleapis.com/auth/calendar.readonly -
https://www.google.com/calendar/feeds
get Events(startTime, endTime, options)
รับเหตุการณ์ทั้งหมดที่เกิดขึ้นภายในช่วงเวลาที่กำหนดและเป็นไปตามเกณฑ์ที่ระบุ
เมธอดนี้จะแสดงกิจกรรมที่เริ่มต้นในช่วงเวลาที่ระบุ สิ้นสุดในช่วงเวลาที่ระบุ หรือครอบคลุมช่วงเวลาที่ระบุ หากไม่ได้ระบุเขตเวลา ระบบจะตีความค่าเวลาในบริบทของเขตเวลาของสคริปต์ ซึ่งอาจแตกต่างจากเขตเวลาของปฏิทิน
โปรดทราบว่าการกรองใน author, search หรือ status จะเกิดขึ้นหลังจากใช้ 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}`);
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
start | Date | จุดเริ่มต้นของช่วงเวลา |
end | Date | จุดสิ้นสุดของช่วงเวลา โดยไม่รวมจุดสิ้นสุด |
options | Object | ออบเจ็กต์ JavaScript ที่ระบุพารามิเตอร์ขั้นสูงตามที่ระบุไว้ด้านล่าง |
พารามิเตอร์ขั้นสูง
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
start | Integer | ดัชนีของเหตุการณ์แรกที่จะแสดง |
max | Integer | จำนวนเหตุการณ์สูงสุดที่จะแสดง |
author | String | อีเมลที่ใช้กรองผลลัพธ์ตามผู้สร้างกิจกรรม |
search | String | ข้อความค้นหาแบบเต็มข้อความที่ใช้กรองผลลัพธ์ |
status | Guest | อาร์เรย์ของสถานะที่ใช้กรองผลลัพธ์ |
รีเทิร์น
Calendar - เหตุการณ์ที่เกิดขึ้นภายในช่วงเวลาและตรงกับเกณฑ์
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.googleapis.com/auth/calendar.readonly -
https://www.google.com/calendar/feeds
get Events For Day(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}`);
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
date | Date | วันที่ที่จะดึงเหตุการณ์ (ใช้เฉพาะวัน ส่วนเวลาจะถูกละเว้น) |
รีเทิร์น
Calendar — เหตุการณ์ที่เกิดขึ้นในวันที่ที่ระบุ
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.googleapis.com/auth/calendar.readonly -
https://www.google.com/calendar/feeds
get Events For Day(date, options)
รับเหตุการณ์ทั้งหมดที่เกิดขึ้นในวันที่ระบุและตรงตามเกณฑ์ที่ระบุ
เมธอดนี้จะแสดงกิจกรรมหากกิจกรรมเริ่มต้นในระหว่างวันนั้น สิ้นสุดในระหว่างวัน หรือ ครอบคลุมวันนั้น
โปรดทราบว่าระบบจะใช้เฉพาะส่วนวันที่ของออบเจ็กต์ Date และจะเพิกเฉยต่อส่วนเวลา ระบบจะตีความวันที่เป็นตั้งแต่เที่ยงคืนของวันนั้นจนถึงเที่ยงคืนของวันถัดไปในเขตเวลาของปฏิทิน
โปรดทราบว่าการกรองใน author, search หรือ status จะเกิดขึ้นหลังจากใช้ 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}`);
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
date | Date | วันที่ที่จะดึงเหตุการณ์ (ใช้เฉพาะวัน ส่วนเวลาจะถูกละเว้น) |
options | Object | ตัวเลือกการกรองขั้นสูง |
พารามิเตอร์ขั้นสูง
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
start | Integer | ดัชนีของเหตุการณ์แรกที่จะแสดง |
max | Integer | จำนวนเหตุการณ์สูงสุดที่จะแสดง |
author | String | อีเมลที่ใช้กรองผลลัพธ์ตามผู้สร้างกิจกรรม |
search | String | ข้อความค้นหาแบบเต็มข้อความที่ใช้กรองผลลัพธ์ |
status | Guest | อาร์เรย์ของสถานะที่ใช้กรองผลลัพธ์ |
รีเทิร์น
Calendar - เหตุการณ์ที่เกิดขึ้นในวันที่ระบุและตรงกับเกณฑ์
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.googleapis.com/auth/calendar.readonly -
https://www.google.com/calendar/feeds
get Id()
รับรหัสของปฏิทิน รหัสสำหรับปฏิทินเริ่มต้นของผู้ใช้คืออีเมลของผู้ใช้
// Opens the calendar by its ID. // To get the user's default calendar, use CalendarApp.getDefaultCalendar(). // TODO(developer): Replace the ID with your own. const calendar = CalendarApp.getCalendarById('222larabrown@gmail.com'); // Gets the ID of the calendar and logs it to the console. const calendarId = calendar.getId(); console.log(calendarId);
รีเทิร์น
String — รหัสของปฏิทิน
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.googleapis.com/auth/calendar.readonly -
https://www.google.com/calendar/feeds
get Name()
รับชื่อปฏิทิน
// 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
get Owned Calendar By Id(id)
รับปฏิทินที่มีรหัสที่ระบุ หากผู้ใช้เป็นเจ้าของ
หากต้องการค้นหารหัสปฏิทิน ให้คลิกลูกศรข้างชื่อปฏิทินใน Google ปฏิทิน แล้วเลือกการตั้งค่าปฏิทิน รหัสจะแสดงที่ด้านล่างของหน้าการตั้งค่า
// Gets a (non-existent) private calendar by ID. const calendar = CalendarApp.getOwnedCalendarById( '123456789@group.calendar.google.com', ); Logger.log('The calendar is named "%s".', calendar.getName());
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
id | String | รหัสปฏิทิน |
รีเทิร์น
Calendar|null - ปฏิทินที่มีรหัสที่ระบุ หรือ null หากไม่มีปฏิทินหรือ
ผู้ใช้ไม่ได้เป็นเจ้าของ
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.googleapis.com/auth/calendar.readonly -
https://www.google.com/calendar/feeds
get Owned Calendars By Name(name)
รับปฏิทินทั้งหมดที่มีชื่อที่ระบุซึ่งผู้ใช้เป็นเจ้าของ ชื่อไม่คำนึงถึงตัวพิมพ์เล็กและตัวพิมพ์ใหญ่
// Gets a private calendar named "Travel Plans". const calendars = CalendarApp.getOwnedCalendarsByName('Travel Plans'); Logger.log('Found %s matching calendars.', calendars.length);
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
name | String | ชื่อปฏิทิน |
รีเทิร์น
Calendar[] — ปฏิทินทั้งหมดที่มีชื่อนี้ซึ่งผู้ใช้เป็นเจ้าของ
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.googleapis.com/auth/calendar.readonly -
https://www.google.com/calendar/feeds
get Time Zone()
รับเขตเวลาของปฏิทิน
// 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
is Hidden()
กำหนดว่าจะซ่อนปฏิทินในอินเทอร์เฟซผู้ใช้หรือไม่
// Opens the calendar by its ID. // TODO(developer): Replace the ID with your own. const calendar = CalendarApp.getCalendarById('222larabrown@gmail.com'); // Determines whether the calendar is hidden in the user interface and logs it // to the console. For the default calendar, you can use CalendarApp.isHidden() // instead. const isHidden = calendar.isHidden(); console.log(isHidden);
รีเทิร์น
Boolean — true หากปฏิทินซ่อนอยู่ในอินเทอร์เฟซผู้ใช้ false หากปฏิทินไม่ซ่อนอยู่
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.googleapis.com/auth/calendar.readonly -
https://www.google.com/calendar/feeds
is My Primary Calendar()
กำหนดว่าปฏิทินเป็นปฏิทินหลักสำหรับผู้ใช้ที่มีผลหรือไม่
// Opens the calendar by its ID. // TODO(developer): Replace the ID with your own. const calendar = CalendarApp.getCalendarById('222larabrown@gmail.com'); // Determines whether the calendar is the default calendar for // the effective user and logs it to the console. // For the default calendar, you can use CalendarApp.isMyPrimaryCalendar() // instead. const isMyPrimaryCalendar = calendar.isMyPrimaryCalendar(); console.log(isMyPrimaryCalendar);
รีเทิร์น
Boolean — true หากปฏิทินเป็นปฏิทินเริ่มต้นสำหรับผู้ใช้ที่มีผล false หากไม่ใช่
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.googleapis.com/auth/calendar.readonly -
https://www.google.com/calendar/feeds
is Owned By Me()
ระบุว่าคุณเป็นเจ้าของปฏิทินหรือไม่
// Gets a calendar by its ID. To get the user's default calendar, use // CalendarApp.getDefault() instead. // TODO(developer): Replace the ID with the calendar ID that you want to use. const calendar = CalendarApp.getCalendarById( 'abc123456@group.calendar.google.com', ); // Determines whether the calendar is owned by you and logs it. console.log(calendar.isOwnedByMe());
รีเทิร์น
Boolean — true หากคุณเป็นเจ้าของปฏิทิน false หากไม่ใช่
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.googleapis.com/auth/calendar.readonly -
https://www.google.com/calendar/feeds
is Selected()
กำหนดว่าจะแสดงกิจกรรมของปฏิทินในอินเทอร์เฟซผู้ใช้หรือไม่
// Gets the user's default calendar. To get a different calendar, // use getCalendarById() instead. const calendar = CalendarApp.getDefaultCalendar(); // Determines whether the calendar's events are displayed in the user interface // and logs it. console.log(calendar.isSelected());
รีเทิร์น
Boolean — true หากกิจกรรมของปฏิทินแสดงในอินเทอร์เฟซผู้ใช้ false หากไม่แสดง
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.googleapis.com/auth/calendar.readonly -
https://www.google.com/calendar/feeds
new Recurrence()
สร้างออบเจ็กต์การเกิดซ้ำใหม่ ซึ่งใช้สร้างกฎสำหรับการเกิดซ้ำของเหตุการณ์ได้
// Creates an event series for a no-meetings day, taking place every Wednesday // in 2013. const recurrence = CalendarApp.newRecurrence() .addWeeklyRule() .onlyOnWeekday(CalendarApp.Weekday.WEDNESDAY) .until(new Date('January 1, 2014')); const eventSeries = CalendarApp.getDefaultCalendar().createAllDayEventSeries( 'No Meetings', new Date('January 2, 2013 03:00:00 PM EST'), recurrence, ); Logger.log(`Event Series ID: ${eventSeries.getId()}`);
รีเทิร์น
Event - ออบเจ็กต์การเกิดซ้ำใหม่ที่ไม่มีการตั้งกฎ (ทำงานเป็นการเกิดซ้ำรายสัปดาห์)
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.googleapis.com/auth/calendar.readonly -
https://www.google.com/calendar/feeds
set Color(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);
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
color | String | Calendar หรือสตริงสีแบบเลขฐานสิบหก
("#rrggbb") |
รีเทิร์น
Calendar — ปฏิทินนี้สำหรับการเชื่อมโยง
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.google.com/calendar/feeds
set Description(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.');
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
description | String | คำอธิบายของปฏิทินนี้ |
รีเทิร์น
Calendar - ปฏิทินนี้สำหรับการเชื่อมโยง
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.google.com/calendar/feeds
set Hidden(hidden)
กำหนดว่าจะให้ปฏิทินปรากฏในอินเทอร์เฟซผู้ใช้หรือไม่
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
hidden | Boolean | true เพื่อซ่อนปฏิทินในอินเทอร์เฟซผู้ใช้ false เพื่อแสดงปฏิทิน |
รีเทิร์น
Calendar - ปฏิทินนี้สำหรับการเชื่อมโยง
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.google.com/calendar/feeds
set Name(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');
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
name | String | ชื่อใหม่ |
รีเทิร์น
Calendar - ปฏิทินนี้สำหรับการเชื่อมโยง
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.google.com/calendar/feeds
set Selected(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);
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
selected | Boolean | true เพื่อแสดงกิจกรรมของปฏิทินในอินเทอร์เฟซผู้ใช้ false
เพื่อซ่อนกิจกรรม |
รีเทิร์น
Calendar - ปฏิทินนี้สำหรับการเชื่อมโยง
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.google.com/calendar/feeds
set Time Zone(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');
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
time | String | เขตเวลาที่ระบุในรูปแบบ "ยาว" (เช่น "America/New_York" ตามที่ระบุโดย Joda.org) |
รีเทิร์น
Calendar — ปฏิทินนี้สำหรับการเชื่อมโยง
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.google.com/calendar/feeds
subscribe To Calendar(id)
ติดตามปฏิทินของผู้ใช้ด้วยรหัสที่ระบุ หากผู้ใช้ได้รับอนุญาตให้ติดตาม
// Subscribe to the calendar "US Holidays". const calendar = CalendarApp.subscribeToCalendar( 'en.usa#holiday@group.v.calendar.google.com', ); Logger.log('Subscribed to the calendar "%s".', calendar.getName());
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
id | String | รหัสของปฏิทินที่จะติดตาม |
รีเทิร์น
Calendar - ปฏิทินที่เพิ่งสมัครรับข้อมูล
ส่ง
Error — หากไม่มีปฏิทินที่มีรหัสนี้
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.google.com/calendar/feeds
subscribe To Calendar(id, options)
ติดตามปฏิทินของผู้ใช้ด้วยรหัสที่ระบุ หากผู้ใช้ได้รับอนุญาตให้ติดตาม
// Subscribe to the calendar "US Holidays", and set it to the color blue. const calendar = CalendarApp.subscribeToCalendar( 'en.usa#holiday@group.v.calendar.google.com', {color: CalendarApp.Color.BLUE}, ); Logger.log('Subscribed to the calendar "%s".', calendar.getName());
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
id | String | รหัสของปฏิทินที่จะติดตาม |
options | Object | ออบเจ็กต์ JavaScript ที่ระบุพารามิเตอร์ขั้นสูงตามที่ระบุไว้ด้านล่าง |
พารามิเตอร์ขั้นสูง
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
color | String | สตริงสีแบบเลขฐานสิบหก ("#rrggbb") หรือค่าจาก Calendar |
hidden | Boolean | ดูว่าปฏิทินซ่อนอยู่ในอินเทอร์เฟซผู้ใช้หรือไม่ (ค่าเริ่มต้น:
false) |
selected | Boolean | ว่าจะแสดงกิจกรรมของปฏิทินในอินเทอร์เฟซผู้ใช้หรือไม่ (ค่าเริ่มต้น: true หากระบุ color ด้วย false
มิฉะนั้น) |
รีเทิร์น
Calendar — ปฏิทินที่เพิ่งติดตาม
ส่ง
Error — หากไม่มีปฏิทินที่มีรหัสนี้
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ หรือขอบเขตที่เหมาะสมจาก REST API ที่เกี่ยวข้อง
-
https://www.googleapis.com/auth/calendar -
https://www.google.com/calendar/feeds