utils.py
branchstable
changeset 6176 33ba2c1dbf10
parent 6134 272cfcc10a28
child 6225 a176e68b7d0d
child 6374 5adf53edfe12
equal deleted inserted replaced
6175:104453c4ed3e 6176:33ba2c1dbf10
   333 except ImportError:
   333 except ImportError:
   334     json_dumps = None
   334     json_dumps = None
   335 
   335 
   336 else:
   336 else:
   337     from logilab.common.date import ustrftime
   337     from logilab.common.date import ustrftime
       
   338 
   338     class CubicWebJsonEncoder(json.JSONEncoder):
   339     class CubicWebJsonEncoder(json.JSONEncoder):
   339         """define a json encoder to be able to encode yams std types"""
   340         """define a json encoder to be able to encode yams std types"""
   340 
   341 
   341         def default(self, obj):
   342         def default(self, obj):
   342             if hasattr(obj, 'eid'):
   343             if hasattr(obj, 'eid'):
   373 
   374 
   374 from logilab.common import date
   375 from logilab.common import date
   375 _THIS_MOD_NS = globals()
   376 _THIS_MOD_NS = globals()
   376 for funcname in ('date_range', 'todate', 'todatetime', 'datetime2ticks',
   377 for funcname in ('date_range', 'todate', 'todatetime', 'datetime2ticks',
   377                  'days_in_month', 'days_in_year', 'previous_month',
   378                  'days_in_month', 'days_in_year', 'previous_month',
   378                  'next_month', 'first_day', 'last_day', 'ustrftime',
   379                  'next_month', 'first_day', 'last_day',
   379                  'strptime'):
   380                  'strptime'):
   380     msg = '[3.6] %s has been moved to logilab.common.date' % funcname
   381     msg = '[3.6] %s has been moved to logilab.common.date' % funcname
   381     _THIS_MOD_NS[funcname] = deprecated(msg)(getattr(date, funcname))
   382     _THIS_MOD_NS[funcname] = deprecated(msg)(getattr(date, funcname))