非推奨。代わりに、People API アドバンスト サービスを使用してください。
連絡先の日付フィールド。
このクラスは Contacts サービスでのみ使用されます。App Script の他の場所で使用される日付には、JavaScript の標準の Date オブジェクトが使用されます。
メソッド
メソッド | 戻り値の型 | 概要 |
---|---|---|
get | Object | このフィールドのラベルを取得します。 |
set |
| このフィールドのラベルを設定します。 |
サポート終了のメソッド
メソッド | 戻り値の型 | 概要 |
---|---|---|
| void | この日付を削除します。 |
| Integer | この日付の月の曜日を取得します。 |
| Month | この日付の月を取得します。 |
| Integer | この日付の年を取得します。 |
|
| 日付を今日に設定します(年なし)。 |
|
| 日付を今日に設定します。 |
|
| このフィールドのラベル(「誕生日」や「記念日」など)を設定します。 |
詳細なドキュメント
getLabel()
このフィールドのラベルを取得します。これは、Field、ExtendedField、または String です。
// 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 Date オブジェクトの場合、
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