Add more aggressive Date: parsing

This commit is contained in:
XANTRONIX Development 2024-11-07 17:10:04 -05:00
parent 9081f5d699
commit 23b854fbc4

View file

@ -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)