Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed2a.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'url:pypi': 0.03; 'url:bitbucket': 0.05; 'combines': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'rfc': 0.09; 'seemed': 0.09; 'subject:string': 0.09; 'subset': 0.09; 'objects.': 0.16; 'readability': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'roy': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'seems': 0.21; 'machine': 0.22; '>>>': 0.22; 'header:User-Agent:1': 0.23; 'right.': 0.26; 'header:X-Complaints- To:1': 0.27; '[1]': 0.29; 'am,': 0.29; 'wonder': 0.29; "i'm": 0.30; '>>>>': 0.31; 'writes:': 0.31; 'url:python': 0.33; 'subject:time': 0.33; 'something': 0.35; 'convert': 0.35; 'there': 0.35; 'dates': 0.36; 'representing': 0.36; 'hi,': 0.36; 'url:org': 0.36; 'message-id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'profile': 0.61; 'times': 0.62; 'smith': 0.68; 'article': 0.77; 'describes': 0.84; 'received:89': 0.85 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Akira Li <4kir4.1i@gmail.com> Subject: Re: converting ISO8601 date and time string representations to datetime Date: Sat, 02 Aug 2014 06:53:44 +0400 References: <53DB3931.8070406@biologie.uni-freiburg.de> Mime-Version: 1.0 Content-Type: text/plain X-Gmane-NNTP-Posting-Host: 89.169.229.68 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) Cancel-Lock: sha1:zkzNMwroDFhJ6qLflLRoG+1ksho= 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: 35 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1406948035 news.xs4all.nl 2861 [2001:888:2000:d::a6]:48765 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:75513 Wolfgang Maier writes: > On 08/01/2014 01:30 AM, Roy Smith wrote: >> In article , >> Albert-Jan Roskam wrote: >> >>>> In article , >>>> Wolfgang Maier wrote: >>>> >>>>> Hi, >>>>> I'm trying to convert ISO8601-compliant strings representing dates or >>>>> dates and times into datetime.datetime objects. >>>> >>>> https://pypi.python.org/pypi/iso8601 >>> >>> Yikes, what a regex. It must have been painstaking to get that right. >>> https://bitbucket.org/micktwomey/pyiso8601/src/2bd28b5d6cd2481674a8b0c54a8bba6 >>> 4ab775f81/iso8601/iso8601.py?at=default >> >> It is a thing of beauty. >> > > No wonder I found it hard to write something that seemed bulletproof ! It seems it supports only some custom subset of ISO 8601. There is rfc 3339 [1] that describes a profile of the ISO 8601 standard. rfc 3339 combines human readability with the simplicity of machine parsing. [1] http://tools.ietf.org/html/rfc3339 -- Akira