newDate
Use the oldDate and newDate variables to create the dates like:
Date colected from the spreadsheet:
oldDate = Mon Mar 01 16:00:00 GMT-03:00 2021
newDate = Wed Mar 03 16:00:00 GMT-03:00 2021
Dates created inside the script:
end_oldDate = Mon Mar 01 17:00:00 GMT-03:00 2021
end_newDate = Wed Mar 03 17:00:00 GMT-03:00 2021
using this:
var end_oldDate = new Date(oldDate);
end_oldDate.setHours(end_oldDate.getHours() + 1);
var end_newDate = new Date(newDate);
end_newDate.setHours(end_newDate.getHours() + 1);
Until this part the script is working fine, and he uses this dates trying to reschedule a event.
I am using conflicts to check with really has a event at the oldDate if it does he tries to set a new beginTime and endTime for this event
var conflicts = calendarID.getEvents(oldDate, end_oldDate);
Logger.log(conflicts);
if (conflicts.length == 1) {
//until here the script in working, what i am doing wrong ?
var event = conflicts.setTime(newDate, end_newDate);
Logger.log('Event ID: ' + event.getId());
} else {
page.getRange(lastRow, 7).setValue("Rejected");
}
This is the error:
TypeError: conflicts.setTime is not a function