เลิกใช้งานแล้ว แต่ให้ใช้บริการขั้นสูงของ People API แทน
ช่องวันที่ในรายชื่อติดต่อ
คลาสนี้ใช้โดยบริการ Contacts เท่านั้น และวันที่ที่ใช้ในที่อื่นๆ ใน App Script จะใช้ออบเจ็กต์ Date มาตรฐานของ JavaScript
เมธอด
วิธีการ | ประเภทการแสดงผล | รายละเอียดแบบย่อ |
---|---|---|
get | Object | รับป้ายกำกับของช่องนี้ |
set |
| ตั้งค่าป้ายกํากับของช่องนี้ |
วิธีการที่เลิกใช้งาน
วิธีการ | ประเภทการแสดงผล | รายละเอียดแบบย่อ |
---|---|---|
| void | ลบวันที่นี้ |
| Integer | รับวันของเดือนสำหรับวันที่นี้ |
| Month | รับเดือนของวันที่นี้ |
| Integer | รับปีของวันที่นี้ |
|
| ตั้งค่าวันที่เป็นวันนี้โดยไม่มีปี |
|
| ตั้งค่าวันที่เป็นวันนี้ |
|
| ตั้งค่าป้ายกำกับของช่องนี้ เช่น "วันเกิด" หรือ "วันครบรอบ" |
เอกสารประกอบโดยละเอียด
getLabel()
รับป้ายกำกับของช่องนี้ ซึ่งอาจเป็นฟิลด์ ExtendedField หรือสตริง
// Logs the label for all the address fields associated with contact // 'John Doe'. This method can be similarly called for any field that has // a label. const contacts = ContactsApp.getContactsByName('John Doe'); const addressFields = contacts[0].getAddresses(); for (let i = 0; i < addressFields.length; i++) { Logger.log(addressFields[i].getLabel()); }
รีเทิร์น
Object
— ป้ายกำกับของช่องนี้
การให้สิทธิ์
สคริปต์ที่ใช้วิธีการนี้ต้องได้รับอนุญาตด้วยขอบเขตต่อไปนี้อย่างน้อย 1 รายการ
-
https://www.google.com/m8/feeds
setLabel(label)
ตั้งค่าป้ายกํากับของช่องนี้
// Sets the label to 'Apartment' for the first address field associated // with contact 'John Doe'. This method can be similarly called for any // field that has a label. const contacts = ContactsApp.getContactsByName('John Doe'); const addressFields = contacts[0].getAddresses(); addressFields[0].setLabel('Apartment');
พารามิเตอร์
ชื่อ | ประเภท | คำอธิบาย |
---|---|---|
label | String | ป้ายกำกับใหม่สำหรับช่องนี้ |
รีเทิร์น
— ช่องนี้มีประโยชน์สำหรับการต่อเชื่อมDate
การให้สิทธิ์
สคริปต์ที่ใช้วิธีการนี้ต้องได้รับอนุญาตด้วยขอบเขตต่อไปนี้อย่างน้อย 1 รายการ
-
https://www.google.com/m8/feeds
วิธีการที่เลิกใช้งาน
deleteDateField()
deleteDateField()
เลิกใช้งานแล้ว ฟังก์ชันนี้เลิกใช้งานแล้วและไม่ควรนำมาใช้ในสคริปต์ใหม่
ลบวันที่นี้
// Deletes all the dates that are set for contact 'John Doe' const contacts = ContactsApp.getContactsByName('John Doe'); const dates = contacts[0].getDates(); for (let i = 0; i < dates.length; i++) { dates[i].deleteDateField(); }
การให้สิทธิ์
สคริปต์ที่ใช้วิธีการนี้ต้องได้รับอนุญาตด้วยขอบเขตต่อไปนี้อย่างน้อย 1 รายการ
-
https://www.google.com/m8/feeds
getDay()
getDay()
เลิกใช้งานแล้ว ฟังก์ชันนี้เลิกใช้งานแล้วและไม่ควรนำมาใช้ในสคริปต์ใหม่
รับวันของเดือนสำหรับวันที่นี้
หมายเหตุ: สําหรับออบเจ็กต์วันที่ JavaScript มาตรฐาน เมธอด
get
จะแสดงผลวันในสัปดาห์แทน
// Logs the day of the birthday for contact 'John Doe' const contacts = ContactsApp.getContactsByName('John Doe'); const birthday = contacts[0].getDates(ContactsApp.Field.BIRTHDAY)[0]; Logger.log(birthday.getDay());
รีเทิร์น
Integer
— วันของเดือน
การให้สิทธิ์
สคริปต์ที่ใช้วิธีการนี้ต้องได้รับอนุญาตด้วยขอบเขตต่อไปนี้อย่างน้อย 1 รายการ
-
https://www.google.com/m8/feeds
getMonth()
getMonth()
เลิกใช้งานแล้ว ฟังก์ชันนี้เลิกใช้งานแล้วและไม่ควรนำมาใช้ในสคริปต์ใหม่
รับเดือนของวันที่นี้
// Logs the month of the birthday for contact 'John Doe' const contacts = ContactsApp.getContactsByName('John Doe'); const birthday = contacts[0].getDates(ContactsApp.Field.BIRTHDAY)[0]; Logger.log(birthday.getMonth());
รีเทิร์น
Month
— เดือน
การให้สิทธิ์
สคริปต์ที่ใช้วิธีการนี้ต้องได้รับอนุญาตด้วยขอบเขตต่อไปนี้อย่างน้อย 1 รายการ
-
https://www.google.com/m8/feeds
getYear()
getYear()
เลิกใช้งานแล้ว ฟังก์ชันนี้เลิกใช้งานแล้วและไม่ควรนำมาใช้ในสคริปต์ใหม่
รับปีของวันที่นี้
// Logs the year of the birthday for contact 'John Doe' const contacts = ContactsApp.getContactsByName('John Doe'); const birthday = contacts[0].getDates(ContactsApp.Field.BIRTHDAY)[0]; Logger.log(birthday.getYear());
รีเทิร์น
Integer
— ปี
การให้สิทธิ์
สคริปต์ที่ใช้วิธีการนี้ต้องได้รับอนุญาตด้วยขอบเขตต่อไปนี้อย่างน้อย 1 รายการ
-
https://www.google.com/m8/feeds
setDate(month, day)
setDate(month, day)
เลิกใช้งานแล้ว ฟังก์ชันนี้เลิกใช้งานแล้วและไม่ควรนำมาใช้ในสคริปต์ใหม่
ตั้งค่าวันที่เป็นวันนี้โดยไม่มีปี
วิธีนี้ใช้ได้กับช่องวันที่ที่ไม่จําเป็นต้องระบุปี เช่น วันเกิด
// Sets the birthday for contact 'John Doe' to April 1 const contacts = ContactsApp.getContactsByName('John Doe'); const birthday = contacts[0].getDates(ContactsApp.Field.BIRTHDAY)[0]; birthday.setDate(ContactsApp.Month.APRIL, 1);
พารามิเตอร์
ชื่อ | ประเภท | คำอธิบาย |
---|---|---|
month | Month | เดือน |
day | Integer | วัน |
รีเทิร์น
— วันที่นี้ มีประโยชน์สำหรับการต่อเชื่อมDate
โยน
Error
— หากช่องวันที่นี้กำหนดให้ต้องระบุปี
การให้สิทธิ์
สคริปต์ที่ใช้วิธีการนี้ต้องได้รับอนุญาตด้วยขอบเขตต่อไปนี้อย่างน้อย 1 รายการ
-
https://www.google.com/m8/feeds
setDate(month, day, year)
setDate(month, day, year)
เลิกใช้งานแล้ว ฟังก์ชันนี้เลิกใช้งานแล้วและไม่ควรนำมาใช้ในสคริปต์ใหม่
ตั้งค่าวันที่เป็นวันนี้
// Sets the birthday for contact 'John Doe' to April 1, 1980 const contacts = ContactsApp.getContactsByName('John Doe'); const birthday = contacts[0].getDates(ContactsApp.Field.BIRTHDAY)[0]; birthday.setDate(ContactsApp.Month.APRIL, 1, 1980);
พารามิเตอร์
ชื่อ | ประเภท | คำอธิบาย |
---|---|---|
month | Month | เดือน |
day | Integer | วัน |
year | Integer | ปี |
รีเทิร์น
— วันที่นี้ มีประโยชน์สำหรับการต่อเชื่อมDate
การให้สิทธิ์
สคริปต์ที่ใช้วิธีการนี้ต้องได้รับอนุญาตด้วยขอบเขตต่อไปนี้อย่างน้อย 1 รายการ
-
https://www.google.com/m8/feeds
setLabel(label)
setLabel(label)
เลิกใช้งานแล้ว ฟังก์ชันนี้เลิกใช้งานแล้วและไม่ควรนำมาใช้ในสคริปต์ใหม่
ตั้งค่าป้ายกำกับของช่องนี้ เช่น "วันเกิด" หรือ "วันครบรอบ"
// Retrieves the first date that's set for contact 'John Doe' and re-labels // it as an anniversary const contacts = ContactsApp.getContactsByName('John Doe'); const firstDate = contacts[0].getDates()[0]; firstDate.setLabel(ContactsApp.Field.ANNIVERSARY);
พารามิเตอร์
ชื่อ | ประเภท | คำอธิบาย |
---|---|---|
label |
| ป้ายกำกับมาตรฐานใหม่ |
รีเทิร์น
— ช่องนี้มีประโยชน์สำหรับการต่อเชื่อมDate
การให้สิทธิ์
สคริปต์ที่ใช้วิธีการนี้ต้องได้รับอนุญาตด้วยขอบเขตต่อไปนี้อย่างน้อย 1 รายการ
-
https://www.google.com/m8/feeds