Sorry if this isn't a full API question. I'm not a strong programmer in any sense, so please forgive me for my ignorance.
I found some scripts to bulk enter events into Google Calendar from Google Sheets. Using this code I'm able to get All Day (using only date 2/22/2016) events to be entered into my calendar, but only if there is one event per day. If I have two dates that are the same I get a duplication error. If I enter time as seen below (2/22/2016 12:44:00) I get an Error saying (Event start time must be before event end time.) Has the API changed? I notice the example code from the API site shows
(February 23, 2016 11:00:00 UTC) UTC time, which I'm not sure if is the reason.
Any guidance is appreciated!
Here's the columns of the Google Sheet:
| Timestamp | Title | Appt. Type | Start Date and Time | End Date and Time | Description | Location | ExportStatus |
| 1/4/2016 13:46:15 | Joe - With John Doe | Initial | 2/22/2016 12:44:00 | 2/22/2016 13:23:00 | Test Description | Conference Room |
|
| 1/4/2016 13:47:16 | Jane - With John Doe | Follow Up
| 2/22/2016 12:44:00 | 2/22/2016 13:23:00 | Test Description | Teacher's Lounge |
|
Here's the code:
function exportEvents(e)
{
var EVENT_EXPORTED = "EVENT_EXPORTED";
var calendar_name = e.parameter.calendar;
var Calendar = CalendarApp.getCalendarsByName(calendar_name);
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = SpreadsheetApp.getActiveSheet();
var startcolumn = 1; // First column of data to process
var numcolumns = 500; // Number of columns to process
var dataRange = sheet.getRange(startcolumn, 2, numcolumns, 8) // Fetch values for each column in the Range.
var data = dataRange.getValues();
for (var i = 1; i < data.length; ++i)
{
var column = data[i];
// Timestamp is in column[1]
var title = column[2]; // 2nd column in spreadsheet "Title"
// Appt. Type is in column[3]
var startDate = column[4]; // 4th column in spreadsheet "Start Date and Time"
var endDate = column[5]; // 5th column in spreadsheet "End Date and Time"
var description = column[6]; // 6th column in spreadsheet "Description"
var location = column[7]; // 7th column in spreadsheet "Location"
var eventExported = column[8];// 8th column in spreadsheet "Import Status"
if (eventExported != EVENT_EXPORTED && title != "") { // Prevents importing duplicates
var cal = CalendarApp.openByName(calendar_name);
var options = {description: description, location: location};
cal.createEvent(title, new Date(startDate), new Date(endDate), options);
// cal.createEvent('Apollo 11 Landing', new Date('February 23, 2016 11:00:00 UTC'), new Date('February 23, 2016 12:00:00 UTC'), options);
sheet.getRange(startRow + i, 7).setValue(EVENT_EXPORTED);
Browser.msgBox("Events Exported");
// Make sure the cell is updated right away in case the script is interrupted
SpreadsheetApp.flush();
}
}
var app = UiApp.getActiveApplication();
app.close();
return app;
}