Ciaran Farrell avatar 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"
+
 try:
     from suds.client import Client
     from suds.transport import TransportError
     logger.debug('''Groupwise.createAppointment with to=%s,subject=%s,message=%s,
       st=%s,et=%s,cc=%s,place=%s'''%(to,subject,message,st,et,cc,place))
     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')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.