35 import urllib |
35 import urllib |
36 |
36 |
37 from six import text_type |
37 from six import text_type |
38 from six.moves.urllib.parse import urlparse, urlunparse, parse_qs, urlencode |
38 from six.moves.urllib.parse import urlparse, urlunparse, parse_qs, urlencode |
39 |
39 |
|
40 import pytz |
40 from logilab.common.date import todate, totime |
41 from logilab.common.date import todate, totime |
41 from logilab.common.textutils import splitstrip, text_to_dict |
42 from logilab.common.textutils import splitstrip, text_to_dict |
42 from logilab.common.decorators import classproperty |
43 from logilab.common.decorators import classproperty |
43 |
44 |
44 from yams.constraints import BASE_CONVERTERS |
45 from yams.constraints import BASE_CONVERTERS |
63 return datetime.strptime(ustr, '%Y-%m-%d %H:%M:%S') |
64 return datetime.strptime(ustr, '%Y-%m-%d %H:%M:%S') |
64 DEFAULT_CONVERTERS['Datetime'] = convert_datetime |
65 DEFAULT_CONVERTERS['Datetime'] = convert_datetime |
65 # XXX handle timezone, though this will be enough as TZDatetime are |
66 # XXX handle timezone, though this will be enough as TZDatetime are |
66 # serialized without time zone by default (UTC time). See |
67 # serialized without time zone by default (UTC time). See |
67 # cw.web.views.xmlrss.SERIALIZERS. |
68 # cw.web.views.xmlrss.SERIALIZERS. |
68 DEFAULT_CONVERTERS['TZDatetime'] = convert_datetime |
69 def convert_tzdatetime(ustr): |
|
70 date = convert_datetime(ustr) |
|
71 date = date.replace(tzinfo=pytz.utc) |
|
72 return date |
|
73 DEFAULT_CONVERTERS['TZDatetime'] = convert_tzdatetime |
69 def convert_time(ustr): |
74 def convert_time(ustr): |
70 return totime(datetime.strptime(ustr, '%H:%M:%S')) |
75 return totime(datetime.strptime(ustr, '%H:%M:%S')) |
71 DEFAULT_CONVERTERS['Time'] = convert_time |
76 DEFAULT_CONVERTERS['Time'] = convert_time |
72 DEFAULT_CONVERTERS['TZTime'] = convert_time |
77 DEFAULT_CONVERTERS['TZTime'] = convert_time |
73 def convert_interval(ustr): |
78 def convert_interval(ustr): |