merge parse_datetime modif tls-sprint
authorFlorent <florent@secondweb.fr>
Mon, 27 Apr 2009 10:26:51 +0200
branchtls-sprint
changeset 1487 7ea2d806de76
parent 1480 d3e3d527daf5 (current diff)
parent 1479 b7494ff85e16 (diff)
child 1488 6da89a703c5a
merge parse_datetime modif
web/controller.py
--- a/web/controller.py	Fri Apr 24 18:53:12 2009 +0200
+++ b/web/controller.py	Mon Apr 27 10:26:51 2009 +0200
@@ -7,7 +7,7 @@
 """
 __docformat__ = "restructuredtext en"
 
-from datetime import timedelta
+import datetime
 
 from cubicweb import typed_eid
 from cubicweb.utils import strptime
@@ -124,12 +124,13 @@
             try:
                 # (adim) I can't find a way to parse a Time with a custom format
                 date = strptime(value, format) # this returns a DateTime
-                return timedelta(0, date.hour *60*60 + date.minute*60 + date.second, 0)
+                return datetime.timedelta(0, date.hour *60*60 + date.minute*60 + date.second, 0)
             except:
                 raise ValueError('can\'t parse %r (expected %s)' % (value, format))
         try:
             format = self.req.property_value('ui.date-format')
-            return strptime(value, format)
+            dt = strptime(value, format)
+            return datetime.date(dt.year, dt.month, dt.day)
         except:
             raise ValueError('can\'t parse %r (expected %s)' % (value, format))