[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.
--- 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):