[IMP]: Put "Datetime In UTC" in Calendar form, which should exported in UTC timezone.
authoratp (Open ERP) <atp@tinyerp.co.in>
Thu, 25 Nov 2010 10:41:08 +0000 (16:11 +0530)
committeratp (Open ERP) <atp@tinyerp.co.in>
Thu, 25 Nov 2010 10:41:08 +0000 (16:11 +0530)
bzr revid: atp@tinyerp.co.in-20101125104108-opxdnyknvd2z11vg

addons/caldav/calendar.py
addons/document/nodes.py

index a51223b..f9615e5 100644 (file)
@@ -248,7 +248,6 @@ class CalDAV(object):
          @param value: Get Attribute Value
          @param type: Get Attribute Type
         """
-        print "valueeeeeeeeee",value,name, type
         if name in self.__attribute__ and self.__attribute__[name]:
             self.__attribute__[name][type] = value
         return True
@@ -302,7 +301,6 @@ class CalDAV(object):
 
         att_data = []
         exdates = []
-        print "tools.get_server_timezone()",tools.get_server_timezone()
         _server_tzinfo = pytz.timezone(tools.get_server_timezone())
 
         for cal_data in child.getChildren():
@@ -337,7 +335,6 @@ class CalDAV(object):
                 self.ical_set(cal_data.name.lower(), ','.join(exvals), 'value')
                 continue
             if cal_data.name.lower() in self.__attribute__:
-                print "_server_tzinfo",cal_data.params.get('X-VOBJ-ORIGINAL-TZID')
                 if cal_data.params.get('X-VOBJ-ORIGINAL-TZID'):
                     self.ical_set('vtimezone', cal_data.params.get('X-VOBJ-ORIGINAL-TZID'), 'value')
                     date_local = cal_data.value.astimezone(_server_tzinfo)
@@ -456,23 +453,19 @@ class CalDAV(object):
                                 dtfield.value = parser.parse(data[map_field])
                                 
                         elif map_type == 'utc'and data[map_field]:
-                            dtfield = vevent.add(field)
-#                            if tzval:
-#                                dtfield.params['TZID'] = [tzval.title()]
-#                                dtfield.value = self.format_date_tz(parser.parse(data[map_field]), tzval.title())
-#                            else:
-#                                import pytz, datetime
-##                            print "tzinfo",tzinfo
-#                            local = pytz.timezone (tools.get_server_timezone())
-#                            naive = datetime.strptime (data[map_field], "%Y-%m-%d %H:%M:%S")
-#                            print "naiteeee",naive.timetz()
-#                            t = naive.utcfromtimestamp(naive.timetz())
-                            print "ttttttttttttt",t
-                            local_dt = naive.replace (local)
-                            utc_dt = local_dt.astimezone (pytz.utc)
-#                            dtfield.value = utc_dt.strftime ("%Y-%m-%d %H:%M:%S")
-                            dtfield.value  = self.format_date_tz(parser.parse(data[map_field]), context.get('tz',False))
-                                
+                            if tzval:
+                                local = pytz.timezone (tzval.title())
+                                naive = datetime.strptime (data[map_field], "%Y-%m-%d %H:%M:%S")
+                                local_dt = naive.replace (tzinfo = local)
+                                utc_dt = local_dt.astimezone (pytz.utc)
+                                vevent.add(field).value = utc_dt
+                            else:
+                               utc_timezone = pytz.timezone ('UTC')
+                               naive = datetime.strptime (data[map_field], "%Y-%m-%d %H:%M:%S")
+                               local_dt = naive.replace (tzinfo = utc_timezone)
+                               utc_dt = local_dt.astimezone (pytz.utc)
+                               vevent.add(field).value = utc_dt
+
                         elif map_type == "timedelta":
                             vevent.add(field).value = timedelta(hours=data[map_field])
                         elif map_type == "many2one":
index 5df8e7d..2cf975d 100644 (file)
@@ -767,10 +767,7 @@ class node_res_dir(node_class):
         # TODO: the write date should be MAX(file.write)..
         self.write_date = dirr.write_date or dirr.create_date
         self.content_length = 0
-<<<<<<< TREE
-=======
         self.unixperms = 040750
->>>>>>> MERGE-SOURCE
         try:
             self.uuser = (dirr.user_id and dirr.user_id.login) or 'nobody'
         except Exception: