This enables the correct recurrence to be found; in particular all-day
events should be search for with only the start date, not the start
timestamp.
def get_gcal_event_by_eventid(gcal_acct,eventId,gcal_id="primary"):
return gcal_acct.events().get(calendarId=gcal_id,eventId=eventId).execute()
def get_gcal_event_by_eventid(gcal_acct,eventId,gcal_id="primary"):
return gcal_acct.events().get(calendarId=gcal_id,eventId=eventId).execute()
-def get_gcal_recur_instance(gcal_acct,gcal_master,start,gcal_id="primary"):
+def get_gcal_recur_instance(gcal_acct,gcal_master,start,is_all_day,stz,
+ gcal_id="primary"):
if gcal_master is None:
logger.warning("Cannot get recurrences from event with null gcal id")
return None
if gcal_master is None:
logger.warning("Cannot get recurrences from event with null gcal id")
return None
+ if is_all_day:
+ os = str(start.astimezone(stz).date())
+ else:
+ os = start.astimezone(stz).isoformat()
ans = gcal_acct.events().instances(calendarId=gcal_id,
eventId=gcal_master,
ans = gcal_acct.events().instances(calendarId=gcal_id,
eventId=gcal_master,
- originalStart=start.isoformat(),
showDeleted=True).execute()
if len(ans['items']) != 1:
logger.error("Searching for recurrance instance returned %d events" % \
showDeleted=True).execute()
if len(ans['items']) != 1:
logger.error("Searching for recurrance instance returned %d events" % \
if master.modified_occurrences is not None:
for mod in master.modified_occurrences:
instance = get_gcal_recur_instance(gcal_acct,master.gcal_link,
if master.modified_occurrences is not None:
for mod in master.modified_occurrences:
instance = get_gcal_recur_instance(gcal_acct,master.gcal_link,
- mod.original_start,gcal_id)
+ mod.original_start,
+ master.is_all_day,
+ master._start_timezone,
+ gcal_id)
if instance is None: #give up after first failure
return
mod_event = get_ex_event_by_itemid(ex_acct.calendar,mod.item_id)
if instance is None: #give up after first failure
return
mod_event = get_ex_event_by_itemid(ex_acct.calendar,mod.item_id)
if master.deleted_occurrences is not None:
for d in master.deleted_occurrences:
instance = get_gcal_recur_instance(gcal_acct,master.gcal_link,
if master.deleted_occurrences is not None:
for d in master.deleted_occurrences:
instance = get_gcal_recur_instance(gcal_acct,master.gcal_link,
+ d.start,
+ master.is_all_day,
+ master._start_timezone,
+ gcal_id)
if instance is None: #give up after any failure
return
if instance["status"] != "cancelled":
if instance is None: #give up after any failure
return
if instance["status"] != "cancelled":