[facets] closes #1569459 (date-range facet with year < 1900) stable
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Mon, 28 Mar 2011 15:23:57 +0200
branchstable
changeset 7117 44775b275d45
parent 7116 dfd4680a23f0
child 7118 e094b3d4eb95
child 7124 56ae3cd5f855
[facets] closes #1569459 (date-range facet with year < 1900) use lgc.date.ustrftime() and lgc.date.ticks2datetime to convert js date ticks and have a chance to handle dates with year < 1900.
web/facet.py
--- a/web/facet.py	Mon Mar 28 15:15:49 2011 +0200
+++ b/web/facet.py	Mon Mar 28 15:23:57 2011 +0200
@@ -53,7 +53,7 @@
 from logilab.mtconverter import xml_escape
 from logilab.common.graph import has_path
 from logilab.common.decorators import cached
-from logilab.common.date import datetime2ticks
+from logilab.common.date import datetime2ticks, ustrftime, ticks2datetime
 from logilab.common.compat import all
 
 from rql import parse, nodes, utils
@@ -981,7 +981,11 @@
 
     def formatvalue(self, value):
         """format `value` before in order to insert it in the RQL query"""
-        return '"%s"' % date.fromtimestamp(float(value) / 1000).strftime('%Y/%m/%d')
+        try:
+            date_value = ticks2datetime(float(value))
+        except (ValueError, OverflowError):
+            return u'"date out-of-range"'
+        return '"%s"' % ustrftime(date_value, '%Y/%m/%d')
 
 
 class HasRelationFacet(AbstractFacet):