59 def convert_datetime(ustr): |
59 def convert_datetime(ustr): |
60 if '.' in ustr: # assume %Y-%m-%d %H:%M:%S.mmmmmm |
60 if '.' in ustr: # assume %Y-%m-%d %H:%M:%S.mmmmmm |
61 ustr = ustr.split('.',1)[0] |
61 ustr = ustr.split('.',1)[0] |
62 return datetime.strptime(ustr, '%Y-%m-%d %H:%M:%S') |
62 return datetime.strptime(ustr, '%Y-%m-%d %H:%M:%S') |
63 DEFAULT_CONVERTERS['Datetime'] = convert_datetime |
63 DEFAULT_CONVERTERS['Datetime'] = convert_datetime |
|
64 # XXX handle timezone, though this will be enough as TZDatetime are |
|
65 # serialized without time zone by default (UTC time). See |
|
66 # cw.web.views.xmlrss.SERIALIZERS. |
|
67 DEFAULT_CONVERTERS['TZDatetime'] = convert_datetime |
64 def convert_time(ustr): |
68 def convert_time(ustr): |
65 return totime(datetime.strptime(ustr, '%H:%M:%S')) |
69 return totime(datetime.strptime(ustr, '%H:%M:%S')) |
66 DEFAULT_CONVERTERS['Time'] = convert_time |
70 DEFAULT_CONVERTERS['Time'] = convert_time |
|
71 DEFAULT_CONVERTERS['TZTime'] = convert_time |
67 def convert_interval(ustr): |
72 def convert_interval(ustr): |
68 return time(seconds=int(ustr)) |
73 return time(seconds=int(ustr)) |
69 DEFAULT_CONVERTERS['Interval'] = convert_interval |
74 DEFAULT_CONVERTERS['Interval'] = convert_interval |
70 |
75 |
71 def extract_typed_attrs(eschema, stringdict, converters=DEFAULT_CONVERTERS): |
76 def extract_typed_attrs(eschema, stringdict, converters=DEFAULT_CONVERTERS): |