diff --git a/Helpers.gs b/Helpers.gs index 317e580..4730bd8 100644 --- a/Helpers.gs +++ b/Helpers.gs @@ -107,7 +107,7 @@ function fetchSourceCalendars(sourceCalendarURLs){ * @return {Calendar} The calendar retrieved or created */ function setupTargetCalendar(targetCalendarName){ - var targetCalendar = Calendar.CalendarList.list({showHidden: true}).items.filter(function(cal) { + var targetCalendar = Calendar.CalendarList.list({showHidden: true, maxResults: 250}).items.filter(function(cal) { return ((cal.summaryOverride || cal.summary) == targetCalendarName) && (cal.accessRole == "owner" || cal.accessRole == "writer"); })[0]; @@ -172,6 +172,15 @@ function parseResponses(responses){ } }); } + + //No need to process calcelled events as they will be added to gcal's trash anyway + result = result.filter(function(event){ + try{ + return (event.getFirstPropertyValue('status').toString().toLowerCase() != "cancelled"); + }catch(e){ + return true; + } + }); result.forEach(function(event){ if (!event.hasProperty('uid')){ @@ -187,7 +196,7 @@ function parseResponses(responses){ icsEventsIds.push(event.getFirstPropertyValue('uid').toString()); } }); - + return result; } @@ -511,6 +520,14 @@ function checkSkipEvent(event, icalEvent){ rrule.setValue(recur); } + var exDates = event.getAllProperties('exdate'); + exDates.forEach(function(e){ + var ex = new ICAL.Time.fromString(e.getFirstValue().toString()); + if (ex < newStartDate){ + event.removeProperty(e); + } + }); + var rdates = event.getAllProperties('rdate'); rdates.forEach(function(r){ var vals = r.getValues(); diff --git a/ical.js.gs b/ical.js.gs index ea20d04..b6a6606 100644 --- a/ical.js.gs +++ b/ical.js.gs @@ -89,7 +89,9 @@ ICAL.helpers = { if ( reqTzid.hasOwnProperty(i) && !vtimezones[i] && - ICAL.TimezoneService.has(i) + ICAL.TimezoneService.has(i) && + ICAL.TimezoneService.get(i).component + ) { vcal.addSubcomponent(ICAL.TimezoneService.get(i).component); } @@ -1320,7 +1322,7 @@ ICAL.design = (function() { /** * Can be set to false to make the parser more lenient. */ - strict: true, + strict: false, /** * The default set for new properties and components if none is specified.