web/views/baseviews.py
changeset 3293 69c0ba095536
parent 3185 bd0126d17e83
parent 3264 5d1f3f6c042d
child 3377 dd9d292b6a6d
--- a/web/views/baseviews.py	Tue Sep 15 15:01:41 2009 +0200
+++ b/web/views/baseviews.py	Thu Sep 17 15:16:53 2009 +0200
@@ -15,6 +15,8 @@
 __docformat__ = "restructuredtext en"
 _ = unicode
 
+from datetime import timedelta
+
 from rql import nodes
 
 from logilab.mtconverter import TransformError, xml_escape, xml_escape
@@ -77,6 +79,13 @@
                 self.w(entity.printable_value(rtype, value, format=format))
                 return
         if etype in ('Time', 'Interval'):
+            if etype == 'Interval' and isinstance(value, (int, long)):
+                # `date - date`, unlike `datetime - datetime` gives an int
+                # (number of days), not a timedelta
+                # XXX should rql be fixed to return Int instead of Interval in
+                #     that case? that would be probably the proper fix but we
+                #     loose information on the way...
+                value = timedelta(days=value)
             # value is DateTimeDelta but we have no idea about what is the
             # reference date here, so we can only approximate years and months
             if format == 'text/html':