Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!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.019 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'problem:': 0.07; 'rfc': 0.09; 'cc:addr:python-list': 0.11; '822': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'gmail.': 0.16; 'parentheses': 0.16; 'subject:python': 0.16; 'sat,': 0.16; 'appropriate': 0.16; 'wrote:': 0.18; 'aug': 0.22; 'cc:addr:python.org': 0.22; 'parse': 0.24; 'skip': 0.24; 'decide': 0.24; 'header': 0.24; 'cc:2**0': 0.24; "i've": 0.25; 'header:In- Reply-To:1': 0.27; 'idea': 0.28; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'fri,': 0.33; 'comment': 0.34; 'skip:d 20': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'date.': 0.36; 'object,': 0.36; 'next': 0.36; 'two': 0.37; 'anything': 0.39; 'recent': 0.39; "couldn't": 0.39; 'remove': 0.60; 'most': 0.60; "you're": 0.61; 'different': 0.65; '30,': 0.65; 'adorn': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=bt9JxlYtqV7PnbfrbgRDxz1dQ58LmTbLjQRYcMCnKHM=; b=acpMwyxrxo14eWWeFR7/Fejb3SwoT9TH/cHbW8H0OSi9eRu8JEfbFbatgaCPGkcKv/ Jy1WDTBh9BXjrGg5jdtO4aaKuHWuh67RdD0PRz32H7Q+mscCtKHKLlS2wXdLfdhE114P x1qSbslLrtOausYlhNhWfjN3jPdCAkg5omSES8Q5l7ElMDyLUV/7DrZIL1ICNkl0FPlX CbGyb5CAV3ODTfNVfCNmbxwnHkthTPC5X9ZGikGDmrK82xzVJFA3c3wQro2oq/OMAezu SpRXystOzxRN7g/NJjkU5HkuHXsxz/OSSjTlPQdD8osAnl1gt0YJrqTqdc3isaIzP4oS 8t3g== MIME-Version: 1.0 X-Received: by 10.50.80.76 with SMTP id p12mr7852697igx.34.1409355627165; Fri, 29 Aug 2014 16:40:27 -0700 (PDT) In-Reply-To: References: Date: Sat, 30 Aug 2014 09:40:27 +1000 Subject: Re: python-dateutil suggestiopn From: Chris Angelico Cc: Python Content-Type: text/plain; charset=UTF-8 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: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1409355635 news.xs4all.nl 2844 [2001:888:2000:d::a6]:45063 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:77301 On Sat, Aug 30, 2014 at 9:35 AM, Skip Montanaro wrote: > I'm using imaplib to download and process messages from Gmail. I use > dateutil.parser.parse to parse the Date header into a datetime object, then > use the most recent date I've seen to decide where to start up on the next > run. > > Every once in awhile, I encountered a Date header I couldn't parse. The > couple I've seen so far have the same problem: two different spellings of > the timezone offset. > > Sat, 23 Aug 2014 16:42:08 -0700 (GMT-07:00) > Fri, 22 Aug 2014 18:14:46 -0700 (GMT-07:00) That's an RFC 822 comment attached to the Date header. I've no idea why you're seeing that - which client feels the need to adorn the date like that??? - but I think it would be appropriate to remove anything in parentheses before attempting to parse the date. ChrisA