I'm trying to do some basic stuff with GAS.(我正在尝试使用GAS做一些基本的事情。)
I would like to retrieve the events from a specific calendar but every time the returned value is 0 (which is impossible since my calendar is full of events).(我想从特定的日历中检索事件,但是每次返回的值都是0时(由于我的日历中充满了事件,所以这是不可能的)。)
I checked the settings in GAS Editor and my calendar.(我检查了GAS编辑器和日历中的设置。) All timeZones are set on GMT+01.(所有时区都在GMT + 01上设置。)
function SearchEventForFirstCall() {
var now = new Date();
Logger.log('NOW: ' + now);
var nowPlusOneMonth = new Date(now.setMonth(now.getMonth()+1));
Logger.log('DATE PLUS 1 MONTH: ' + nowPlusOneMonth);
var calendar = CalendarApp.getCalendarById('[email protected]');
Logger.log('CALENDAR: ' + calendar);
var events = calendar.getEvents(now,nowPlusOneMonth);
Logger.log('EVENTS: ' + events.length);
}
Here's the transcript:(这是成绩单:)
1[19-11-28 20:43:54:617 CET] Starting execution
2[19-11-28 20:43:54:706 CET] Logger.log([NOW : Thu Nov 28 2019 20:43:54 GMT+0100 (CET), []]) [0 seconds]
3[19-11-28 20:43:54:706 CET] Logger.log([DATE PLUS 1 MONTH : Sat Dec 28 2019 20:43:54 GMT+0100 (CET), []]) [0 seconds]
4[19-11-28 20:43:54:850 CET] CalendarApp.getCalendarById([[email protected]]) [0.142 seconds]
5[19-11-28 20:43:54:850 CET] Logger.log([CALENDAR : Calendar, []]) [0 seconds]
6[19-11-28 20:43:55:094 CET] CalendarApp.Calendar.getEvents([Sat Dec 28 11:43:54 PST 2019, Sat Dec 28 11:43:54 PST 2019]) [0.242 seconds]
7[19-11-28 20:43:55:095 CET] Logger.log([Events: 0, []]) [0 seconds]
8[19-11-28 20:43:55:097 CET] Execution succeeded [0.391 seconds total runtime]
Why is there two identical PST dates (6th line in the transcript)?(为什么会有两个相同的PST日期(成绩单的第六行)?)
Using this solve the problem.(用这个解决问题。)
var now = new Date('2019-11-28');
var nowPlusOneMonth = new Date('2019-12-28');
Date format seems to be the issue.(日期格式似乎是问题所在。)
ask by Yotho translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…