web/facet.py
branchstable
changeset 7117 44775b275d45
parent 7070 5f8e52d722c5
child 7203 e0e802afa8e1
equal deleted inserted replaced
7116:dfd4680a23f0 7117:44775b275d45
    51 from datetime import date, datetime, timedelta
    51 from datetime import date, datetime, timedelta
    52 
    52 
    53 from logilab.mtconverter import xml_escape
    53 from logilab.mtconverter import xml_escape
    54 from logilab.common.graph import has_path
    54 from logilab.common.graph import has_path
    55 from logilab.common.decorators import cached
    55 from logilab.common.decorators import cached
    56 from logilab.common.date import datetime2ticks
    56 from logilab.common.date import datetime2ticks, ustrftime, ticks2datetime
    57 from logilab.common.compat import all
    57 from logilab.common.compat import all
    58 
    58 
    59 from rql import parse, nodes, utils
    59 from rql import parse, nodes, utils
    60 
    60 
    61 from cubicweb import Unauthorized, typed_eid
    61 from cubicweb import Unauthorized, typed_eid
   979     def wdgclass(self):
   979     def wdgclass(self):
   980         return DateFacetRangeWidget
   980         return DateFacetRangeWidget
   981 
   981 
   982     def formatvalue(self, value):
   982     def formatvalue(self, value):
   983         """format `value` before in order to insert it in the RQL query"""
   983         """format `value` before in order to insert it in the RQL query"""
   984         return '"%s"' % date.fromtimestamp(float(value) / 1000).strftime('%Y/%m/%d')
   984         try:
       
   985             date_value = ticks2datetime(float(value))
       
   986         except (ValueError, OverflowError):
       
   987             return u'"date out-of-range"'
       
   988         return '"%s"' % ustrftime(date_value, '%Y/%m/%d')
   985 
   989 
   986 
   990 
   987 class HasRelationFacet(AbstractFacet):
   991 class HasRelationFacet(AbstractFacet):
   988     """This class simply filter according to the presence of a relation
   992     """This class simply filter according to the presence of a relation
   989     (whatever the entity at the other end). It display a simple checkbox that
   993     (whatever the entity at the other end). It display a simple checkbox that