/offlineimap/head: changeset 146

More date format workarounds. Now accept a valid format but invalid
data (ie, year 0102).
This commit is contained in:
jgoerzen 2002-07-18 23:59:56 +01:00
parent 6a073f3f43
commit 6c2e2deade
1 changed files with 7 additions and 1 deletions

View File

@ -106,9 +106,15 @@ class IMAPFolder(BaseFolder):
message = rfc822.Message(StringIO(content))
mid = imapobj._quote(message.getheader('Message-Id'))
datetuple = rfc822.parsedate(message.getheader('Date'))
# Will be None if missing or not in a valid format.
if datetuple == None:
datetuple = time.localtime()
date = imaplib.Time2Internaldate(datetuple)
try:
date = imaplib.Time2Internaldate(datetuple)
except ValueError:
# Argh, sometimes it's a valid format but year is 0102
# or something. Argh.
date = imaplib.Time2Internaldate(time.localtime())
if content.find("\r\n") == -1: # Convert line endings if not already
content = content.replace("\n", "\r\n")