使用应用程序脚本和谷歌日历,我得到了同名的事件:
function authorize() {
var oauthConfig = UrlFetchApp.addOAuthService("calendar");
var scope = "https://www.googleapis.com/auth/calendar";
oauthConfig.setConsumerKey("anonymous");
oauthConfig.setConsumerSecret("anonymous");
oauthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope="+scope);
oauthConfig.setAuthorizationUrl("https://accounts.google.com/OAuthAuthorizeToken");
oauthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken");
}
function beginEnd(calId, eventName){
authorize();
var key = "...";
var query = encodeURIComponent(eventName);
calId = encodeURIComponent(calId);
var params = {
method: "get",
oAuthServiceName: "calendar",
oAuthUseToken: "always",
};
var url = "https://www.googleapis.com/calendar/v3/calendars/"+
calId+"/events?q=" + query + "&key=" + key;
var request = UrlFetchApp.fetch(url, params);
var response = Utilities.jsonParse(request.getContentText());
var items = response.items;
for ( i = 0 ; i < items.length ; i++){
var start = (items[i].start.dateTime);
var end = (items[i].end.dateTime);
Logger.log( [start,end]);
}
}
但是,当我尝试将开始转换为新日期时:
var start = (items[i].start.dateTime);
Logger.log(start);
Logger.log( new Date(start) );
我明白了
2013-01-21T15:00:00-03:00
Wed Dec 31 16:00:00 PST 1969
为什么 ?