gpt4 book ai didi

javascript - 如何使用谷歌通讯录服务读取日期(出生)

转载 作者:行者123 更新时间:2023-11-28 02:37:37 26 4
gpt4 key购买 nike

抱歉我的英语不好......我尝试使用 Google Apps 脚本 - 通讯录服务读取通讯录中的信息。

姓名、电子邮件、地址、电话没有问题,但我无法读取日期(我想获取联系人的出生日期)。如何读取“日期字段”?

    for (var i=0; i<contacts.length; i++) {
Name = contacts[i].getFullName();

EmailArray = contacts[i].getEmails(ContactsApp.Field.HOME_EMAIL);
if (EmailArray.length)
Email = contacts[i].getEmails(ContactsApp.Field.HOME_EMAIL)[0].getAddress();
if (!Email){
EmailArray = contacts[i].getEmails(ContactsApp.Field.WORK_EMAIL);
if (EmailArray.length)
Email = contacts[i].getEmails(ContactsApp.Field.WORK_EMAIL)[0].getAddress();
}

AddressArray = contacts[i].getAddresses(ContactsApp.Field.HOME_ADDRESS);
for ( var j = 0; j < AddressArray.length; j++ ) {
Address = AddressArray[j].getAddress();
AddressSplit = Address.split(/\r\n|\r|\n/);
Rue = AddressSplit[0];
Code = AddressSplit[1].split(" ")[0];
Ville = AddressSplit[1].split(" ")[1];
}

var HomePhone = contacts[i].getHomePhone();
var MobilePhone = contacts[i].getMobilePhone();

//HERE IS THE PROBLEM
DatesArray = contacts[i].getDates();
// Never pass here... How to read the DateField ?
for ( var j = 0; j < DatesArray.lenght; j++ ) {
var date = contacts[i].getDates()[j];
var day = date.getDay();
var month = date.getMonth();
var year = date.getYear();
}
}

最佳答案

我找到了解决方案......过了一会儿!联系人服务未记录...

var dateArray = new Array(), day, month = new String, year;
var monthArray = ["0", "JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER"];

dateArray = contacts[i].getDates(ContactsApp.Field.BIRTHDAY);
for(var j in dateArray){
day = dateArray[j].getDay();
month = monthArray.indexOf(dateArray[j].getMonth().toString());
year = dateArray[j].getYear();
sheet.getRange(1*i+2, 3, 1, 1).setValue(day + "/" + month + "/" + year);
}

关于javascript - 如何使用谷歌通讯录服务读取日期(出生),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13221265/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com