converting ISO8601 date and time string representations to datetime
wolfgang.maier at biologie.uni-freiburg.de
Thu Jul 31 15:29:40 CEST 2014
On 31.07.2014 15:13, Roy Smith wrote:
> On Jul 31, 2014, at 8:59 AM, Skip Montanaro wrote:
>> On Thu, Jul 31, 2014 at 6:52 AM, Roy Smith <roy at panix.com> wrote:
>>> Sadly, the stdlib datetime really doesn't make life easy for dealing
>>> with ISO-8601. Dateutil is the classic answer, but it's slow.
>> A useful feature for dateutil would be a "sniff" function which, given
>> a date string that dateutil.parser.parse can handle, instead returns a
>> format string suitable for use with time.strptime.
> +0.8. But, even more than that, dateutil should come with a library of strings for common formats, and a built-in function to parse 8601. It is, after all, the international standard.
Thanks for your feedback.
I'll have a look at isodate as you suggested, Roy.
What this makes me wonder is whether there shouldn't be a builtin method
for parsing ISO-8601 strings in the stdlib datetime module, just as
there is .isoformat() for the reverse action already.
Alternatively, the existing format argument to datetime.strptime() could
be made optional and when absent, strptime() could try to parse ISO-8601 ?
More information about the Python-list