Ciaran Farrell committed 5d7e8c7

l2u converts between local and utc but it is VERY SHAKY, especially because we subtract the global delta

Comments (0)

Files changed (1)

 from random import  sample
 from ConfigParser import NoOptionError
 from string import digits, ascii_letters
-from time import sleep,timezone
+from time import sleep,timezone,gmtime,mktime,strptime
 from operator import itemgetter
 import sys,os,json,logging,ConfigParser,base64,pkgutil,tempfile
-gwtimeformat = "%Y-%m-%dT%H:%M:%SZ"
 utcoffset = timezone / -(60*60)
 gdelta = timedelta(hours=utcoffset)
+sttimeformat = "%Y-%m-%d %H:%M"
+def l2u(lt):
+  ''' lt is a datetime representing localtime'''
+  lts=lt.strftime(sttimeformat)
+  ut = gmtime(mktime(strptime(lts,sttimeformat)))
+  # TODO - have no idea of how the delta below works
+  return datetime.fromtimestamp(mktime(ut))-gdelta
+gwtimeformat = "%Y-%m-%dT%H:%M:%SZ"
     from suds.client import Client
     from suds.transport import TransportError
     logger.debug('''Groupwise.createAppointment with to=%s,subject=%s,message=%s,
     logger.debug('Adding the gdelta timedelta to st and et')
-    st = st+gdelta
-    et = st+gdelta
+    st = l2u(st)
+    et = l2u(et)
     logger.debug('Getting user list for %s'%to)
     users = self.getUserList(to)
     app = self.client.factory.create('ns2:Appointment')