Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'feedback.': 0.04; 'argument': 0.05; 'string': 0.09; 'already.': 0.09; 'builtin': 0.09; 'parsing': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'slow.': 0.09; 'subject:string': 0.09; 'cc:addr:python-list': 0.11; '6:52': 0.16; 'absent,': 0.16; 'optional': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'roy': 0.16; 'suggested,': 0.16; 'which,': 0.16; 'wrote:': 0.18; 'library': 0.18; 'all,': 0.19; 'thu,': 0.19; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'header :User-Agent:1': 0.23; '31,': 0.24; 'module,': 0.24; 'parse': 0.24; "shouldn't": 0.24; 'skip': 0.24; 'cc:2**0': 0.24; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'feature': 0.29; 'am,': 0.29; 'wonder': 0.29; "doesn't": 0.30; 'subject:time': 0.33; 'skip:d 20': 0.34; 'could': 0.34; 'common': 0.35; 'but': 0.35; 'there': 0.35; 'really': 0.36; 'method': 0.36; 'useful': 0.36; 'thanks': 0.36; "i'll": 0.36; 'should': 0.36; 'to:addr:python-list': 0.38; 'that,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'even': 0.60; 'easy': 0.60; 'more': 0.64; 'life': 0.66; 'reverse': 0.68; 'smith': 0.68; 'jul': 0.74; '2014,': 0.84; 'sfxlen:4': 0.84; 'pfxlen:big': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Wolfgang Maier Subject: Re: converting ISO8601 date and time string representations to datetime Date: Thu, 31 Jul 2014 15:29:40 +0200 References: <1FFF599B-DD78-4829-BFE9-58DF0CD96A0F@panix.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Cc: Python X-Gmane-NNTP-Posting-Host: bio-192-52-34-196.mobile.uni-freiburg.de User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0 In-Reply-To: <1FFF599B-DD78-4829-BFE9-58DF0CD96A0F@panix.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1406813397 news.xs4all.nl 2856 [2001:888:2000:d::a6]:50015 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:75417 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 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 ? Wolfgang