converters¶
- class ISODateTime(*args, **kwargs)[source]¶
Bases:
ConverterConverts an ISO-8601 datetime string into a datetime.datetime.
- async convert(_context, datetime_string)[source]¶
Converts an ISO-8601
datetime_stringinto adatetime.datetimeobject.The converter is flexible in the formats it accepts, as it uses the
isoparsemethod ofdateutil.parser. In general, it accepts datetime strings that start with a date, optionally followed by a time. Specifying a timezone offset in the datetime string is supported, but thedatetimeobject will be converted to UTC. If no timezone is specified, the datetime will be assumed to be in UTC already. In all cases, the returned object will have the UTC timezone.See: https://dateutil.readthedocs.io/en/stable/parser.html#dateutil.parser.isoparse
Formats that are guaranteed to be valid by our tests are:
YYYY-mm-ddTHH:MM:SSZ|YYYY-mm-dd HH:MM:SSZYYYY-mm-ddTHH:MM:SS±HH:MM|YYYY-mm-dd HH:MM:SS±HH:MMYYYY-mm-ddTHH:MM:SS±HHMM|YYYY-mm-dd HH:MM:SS±HHMMYYYY-mm-ddTHH:MM:SS±HH|YYYY-mm-dd HH:MM:SS±HHYYYY-mm-ddTHH:MM:SS|YYYY-mm-dd HH:MM:SSYYYY-mm-ddTHH:MM|YYYY-mm-dd HH:MMYYYY-mm-ddYYYY-mmYYYY
Note
ISO-8601 specifies a
Tas the separator between the date and the time part of the datetime string. The converter accepts both aTand a single space character.- Return type: