Add more aggressive Date: parsing
This commit is contained in:
parent
9081f5d699
commit
23b854fbc4
1 changed files with 4 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
|||
import re
|
||||
import enum
|
||||
import dateparser
|
||||
|
||||
from dateparser.search import search_dates
|
||||
|
||||
class MBoxReaderError(Exception):
|
||||
pass
|
||||
|
@ -100,10 +101,10 @@ class MBoxMessage():
|
|||
self.line = line
|
||||
|
||||
def header(self, key: str):
|
||||
return self.headers[key.lower()]
|
||||
return self.headers.get(key.lower())
|
||||
|
||||
def date(self):
|
||||
return dateparser.parse(self.headers['date'])
|
||||
return search_dates(self.headers['date'])[0][1]
|
||||
|
||||
def is_first_line(self):
|
||||
return len(self.headers) == 1 and (self.body == '' or self.body is None)
|
||||
|
|
Loading…
Add table
Reference in a new issue