time changes when added to google calender by google appscript and spreedsheet: code for app script (only time portion):
function setUpCalendar_(values, range) {
var cal = CalendarApp.createCalendar('Conference Calendar');
Browser.msgBox('Calender time zone: ' + cal.getTimeZone());
//to check timezone for debugging.
for (var i = 1; i < values.length; i++) {
var session = values[i];
var title = session[0];
var start = joinDateAndTime_(session[1], session[2]);
var end = joinDateAndTime_(session[1], session[3]);
var options = {location: session[4], sendInvites: true};
var event = cal.createEvent(title, start, end, options)
.setGuestsCanSeeGuests(false);
//session[5] = event.getId();
///====:::: test :::: replacingsession[5] with values[i][5]
}
range.setValues(values);
// Store the ID for the Calendar, which is needed to retrieve events by ID.
ScriptProperties.setProperty('calId', cal.getId());
}
function joinDateAndTime_(date, time) {
date = new Date(date);
date.setHours(time.getHours());
date.setMinutes(time.getMinutes());
Browser.msgBox(date); // to check time for debuging.
return date;
}
Link to spreadsheet with script:
https://docs.google.com/spreadsheet/ccc?key=0AorrYgKfVJpQdEdBY2lYdEpIUUc0TlRRUkNlNmRPTWc&usp=sharing
steps taken so far: 1. changed timezone of spreadsheet to locale. 2. changed timezone of calender to locale.
result: different time in spreadsheet and calender.
issue: must be same time in spreadsheet and calender.
references:
calendarApp createEvent added event on wrong day
How to use timeZone of calendar to set timeZone for date object