Class DateField

날짜필드

지원 중단되었습니다. 대신 People API 고급 서비스를 사용하세요.

연락처의 날짜 필드

이 클래스는 연락처 서비스에서만 사용되며 Apps Script의 다른 곳에서 사용되는 날짜는 JavaScript의 표준 날짜 객체를 사용합니다.

메서드

메서드반환 유형간략한 설명
getLabel()Object이 필드의 라벨을 가져옵니다.
setLabel(label)DateField이 필드의 라벨을 설정합니다.
메서드반환 유형간략한 설명
deleteDateField()void이 날짜를 삭제합니다.
getDay()Integer이 날짜의 월 중 날짜를 가져옵니다.
getMonth()Month이 날짜의 월을 가져옵니다.
getYear()Integer이 날짜의 연도를 가져옵니다.
setDate(month, day)DateField날짜를 올해의 오늘로 설정합니다(연도 제외).
setDate(month, day, year)DateField날짜를 오늘로 설정합니다.
setLabel(label)DateField이 필드의 라벨(예: '생일' 또는 '기념일')을 설정합니다.

자세한 문서

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: 이 필드의 라벨입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.

  • 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');

매개변수

이름유형설명
labelString이 필드의 새 라벨

리턴

DateField: 연결에 유용한 필드

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.

  • https://www.google.com/m8/feeds

지원 중단된 메서드

지원 중단되었습니다. 이 함수는 지원 중단되었으며 새 스크립트에서 사용해서는 안 됩니다.

이 날짜를 삭제합니다.

// 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();
}

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.

  • https://www.google.com/m8/feeds

지원 중단되었습니다. 이 함수는 지원 중단되었으며 새 스크립트에서 사용해서는 안 됩니다.

이 날짜의 월 중 날짜를 가져옵니다.

참고: 표준 JavaScript Date 객체의 경우 getDay() 메서드는 요일을 대신 반환합니다.

// 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: 일

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.

  • https://www.google.com/m8/feeds

지원 중단되었습니다. 이 함수는 지원 중단되었으며 새 스크립트에서 사용해서는 안 됩니다.

이 날짜의 월을 가져옵니다.

// 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: 월

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.

  • https://www.google.com/m8/feeds

지원 중단되었습니다. 이 함수는 지원 중단되었으며 새 스크립트에서 사용해서는 안 됩니다.

이 날짜의 연도를 가져옵니다.

// 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: 연도

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.

  • https://www.google.com/m8/feeds

지원 중단되었습니다. 이 함수는 지원 중단되었으며 새 스크립트에서 사용해서는 안 됩니다.

날짜를 올해의 오늘로 설정합니다(연도 제외).

이 메서드는 생일과 같이 연도가 필요하지 않은 날짜 필드에만 적용됩니다.

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

매개변수

이름유형설명
monthMonth
dayInteger하루

리턴

DateField: 연결에 유용한 날짜입니다.

생성 값

Error: 이 날짜 필드에 연도가 필요한 경우

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.

  • https://www.google.com/m8/feeds

지원 중단되었습니다. 이 함수는 지원 중단되었으며 새 스크립트에서 사용해서는 안 됩니다.

날짜를 오늘로 설정합니다.

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

매개변수

이름유형설명
monthMonth
dayInteger하루
yearInteger연도

리턴

DateField: 연결에 유용한 날짜입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.

  • https://www.google.com/m8/feeds

지원 중단되었습니다. 이 함수는 지원 중단되었으며 새 스크립트에서 사용해서는 안 됩니다.

이 필드의 라벨(예: '생일' 또는 '기념일')을 설정합니다.

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

매개변수

이름유형설명
labelField새 표준 라벨

리턴

DateField: 연결에 유용한 필드

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.

  • https://www.google.com/m8/feeds