web/views/baseviews.py
branchstable
changeset 3235 bad0ff9b0c13
parent 2996 866a2c135c33
child 3236 df31dbf3225e
--- a/web/views/baseviews.py	Mon Sep 14 16:24:01 2009 +0200
+++ b/web/views/baseviews.py	Tue Sep 15 16:31:45 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,10 @@
                 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
+                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':