]> code.delx.au - offlineimap/commitdiff
Fix up date parsing to use message date if no rtime is available
authorJohn Goerzen <jgoerzen@complete.org>
Tue, 22 Aug 2006 01:13:39 +0000 (02:13 +0100)
committerJohn Goerzen <jgoerzen@complete.org>
Tue, 22 Aug 2006 01:13:39 +0000 (02:13 +0100)
offlineimap/folder/IMAP.py

index 8a4f7e41741ba18e9b6d560052d5f71e8d52d72c..d89059670e2985668192ae793365f467b2369cf4 100644 (file)
@@ -197,9 +197,15 @@ class IMAPFolder(BaseFolder):
             # This backend always assigns a new uid, so the uid arg is ignored.
             # In order to get the new uid, we need to save off the message ID.
 
+            message = rfc822.Message(StringIO(content))
+            datetuple_msg = rfc822.parsedate(message.getheader('Date'))
+            # Will be None if missing or not in a valid format.
+
             # If time isn't known
-            if rtime == None:
+            if rtime == None and datetuple_msg == None:
                 datetuple = time.localtime()
+            elif rtime == None:
+                datetuple = datetuple_msg
             else:
                 datetuple = time.localtime(rtime)