diff options
author | Pierre-Yves David <pierre-yves.david@logilab.fr> | 2008-06-18 17:45:05 +0200 |
---|---|---|
committer | Pierre-Yves David <pierre-yves.david@logilab.fr> | 2008-06-18 17:45:05 +0200 |
commit | e401a65105a21f62a35c3d04a16bb8bdec58880d (patch) | |
tree | cdbbe147fff237e615319a9a8c4ef30157275772 /umessage.py | |
parent | 2c908ac0b1c8131f340d8446c0b6ce4fdda32c46 (diff) | |
download | logilab-common-e401a65105a21f62a35c3d04a16bb8bdec58880d.tar.gz |
search date in envelope if Date: header is missing
Diffstat (limited to 'umessage.py')
-rw-r--r-- | umessage.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/umessage.py b/umessage.py index 52111f0..1ab9125 100644 --- a/umessage.py +++ b/umessage.py @@ -110,16 +110,25 @@ class UMessage: persons.append((name, mail)) return persons - def date(self): + def date(self, alternative_source=False): """return a mx.DateTime object for the email's date or None if no date is set or if it can't be parsed """ value = self.get('date') - if value: + if value is None and alternative_source: + unix_from = self.message.get_unixfrom() + if unix_from is not None: + try: + value = unix_from.split(" ", 2)[2] + except IndexError: + pass + + if value is not None: datetuple = parsedate(value) if datetuple: return DateTime(*datetuple[:6]) - return None + else: + return None |