[英]Google Calendar event from sheets script ends a day early
我有一個工作表文件,當單擊按鈕時會創建一個日歷事件。 日歷事件基於用戶輸入的截止日期、腳本創建的開始日期、輸入的位置和輸入的描述,這些都是從電子表格中的某些單元格中提取的。 問題是當我 go 到日歷時,事件在截止日期前一天(或截止日期的開始)結束,我希望它顯示整個截止日期。 例如,如果我在電子表格中輸入了 7 月 17 日的截止日期,那么當我創建日歷事件時,它只會運行到 16 日。 有沒有辦法讓事件安排到一天結束,或者有一種簡單的方法可以在腳本中將結束日期偏移一天。
var Description = sheetTemplate.getRange('B12').getValue(); //gets discription from Cell B12
var Location = sheetTemplate.getRange('C5') .getValue(); //gets location of work order from cell C5
var StartDate = sheetTemplate.getRange('C4').getValue(); //Start Date from Cell C4
var DueDate = sheetTemplate.getRange('E5').getValue(); //Gets Due Date From Cell E5
//This portion of the code schedules the WO on the calendar//
var eventCal = CalendarApp.getCalendarById("XXXXX") ;//Get the Maintenance Calendar
var options = { 'location': Location,
'description':Description
} //sets event details
var WOevent = eventCal.createAllDayEvent(WOname,StartDate,DueDate,options);//creates a calendar event
WOevent.setColor('10') // sets the color of the calendar event to green
這可以通過new Date(ms)
來完成:
var DueDate = sheetTemplate.getRange('E5').getValue();
DueDate = new Date(DueDate.getTime() + 24*60*60*1000);
createAllDayEvent()
這允許您指定 DueDate 的結束時間:
var DueDate = sheetTemplate.getRange('E5').getValue();
DueDate = new Date(DueDate);
DueDate.setHours(23);
DueDate.setMinutes(59);
var WOevent = eventCal.createEvent(WOname,StartDate,DueDate,options);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.