chiark / gitweb /
Use event timezone for events (where available)
authorMatthew Vernon <mv3@sanger.ac.uk>
Tue, 11 Dec 2018 15:06:31 +0000 (15:06 +0000)
committerMatthew Vernon <mv3@sanger.ac.uk>
Tue, 11 Dec 2018 15:06:31 +0000 (15:06 +0000)
This required a fix in the upstream exchange library (to properly
understand the MS timezones), but now we can use the event's timezone.

gooswapper.py

index 24b7a2fd229c59fc400ee7b6852557f79ce4e95e..05db810ff0b5f226d91a6357e734815d1ccfbc76 100644 (file)
@@ -270,14 +270,24 @@ def modify_recurring(ex_acct,gcal_acct,gcal_tz,
 def build_gcal_event_from_ex(event,gcal_tz):
     gevent={}
     gevent["summary"]=event.subject
 def build_gcal_event_from_ex(event,gcal_tz):
     gevent={}
     gevent["summary"]=event.subject
+    #Use the event's timezones if possible, otherwise fall back to the
+    #target calendar timezone
+    if event._start_timezone is not None:
+        stz = event._start_timezone
+    else:
+        stz = gcal_tz
+    if event._end_timezone is not None:
+        etz = event._end_timezone
+    else:
+        etz = gcal_tz
     if event.is_all_day:
     if event.is_all_day:
-        gevent["end"]={"date": str(event.end.astimezone(gcal_tz).date())}
-        gevent["start"]={"date": str(event.start.astimezone(gcal_tz).date())}
+        gevent["end"]={"date": str(event.end.astimezone(etz).date())}
+        gevent["start"]={"date": str(event.start.astimezone(stz).date())}
     else:
     else:
-        gevent["end"]={"dateTime": event.end.astimezone(gcal_tz).isoformat(),
-                       "timeZone": str(gcal_tz)}
-        gevent["start"]={"dateTime": event.start.astimezone(gcal_tz).isoformat(),
-                         "timeZone": str(gcal_tz)}
+        gevent["end"]={"dateTime": event.end.astimezone(etz).isoformat(),
+                       "timeZone": str(etz)}
+        gevent["start"]={"dateTime": event.start.astimezone(stz).isoformat(),
+                         "timeZone": str(stz)}
     if event.text_body is not None and event.text_body.strip() != '':
         gevent["description"] = event.text_body
     if event.location is not None:
     if event.text_body is not None and event.text_body.strip() != '':
         gevent["description"] = event.text_body
     if event.location is not None: