fix date rounding issue in DateFacetRangeWidget stable
authorFlorent <florent@secondweb.fr>
Tue, 23 Jun 2009 15:39:30 +0200
branchstable
changeset 2149 6a631ec5cc71
parent 2148 2b2b9626a98f
child 2151 d653e4c944d7
fix date rounding issue in DateFacetRangeWidget
web/facet.py
--- a/web/facet.py	Tue Jun 23 15:37:51 2009 +0200
+++ b/web/facet.py	Tue Jun 23 15:39:30 2009 +0200
@@ -10,7 +10,7 @@
 
 from itertools import chain
 from copy import deepcopy
-from datetime import date
+from datetime import date, datetime
 
 from logilab.mtconverter import html_escape
 
@@ -683,8 +683,15 @@
 
 
 class DateFacetRangeWidget(FacetRangeWidget):
+
     formatter = 'function (value) {return (new Date(parseFloat(value))).strftime(DATE_FMT);}'
+
+    def round_max_value(self, d):
+        'round to upper value to avoid filtering out the max value'
+        return datetime(d.year, d.month, d.day + 1)
+
     def __init__(self, facet, minvalue, maxvalue):
+        maxvalue = self.round_max_value(maxvalue)
         super(DateFacetRangeWidget, self).__init__(facet,
                                                    datetime2ticks(minvalue),
                                                    datetime2ticks(maxvalue))