Skip to content

Commit

Permalink
Update message.py
Browse files Browse the repository at this point in the history
Add support for emails with another date. See Miksus#12
  • Loading branch information
jaboto authored Jan 18, 2024
1 parent 07a865c commit 869bfee
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion redbox/models/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ def subject(self) -> str:
def date(self) -> Dict[str, str]:
headers = {k.lower(): v for k, v in self.headers.items()}
date = headers['date']
return datetime.datetime.strptime(date, "%a, %d %b %Y %H:%M:%S %z")
try:
return datetime.datetime.strptime(date, "%a, %d %b %Y %H:%M:%S %z")
except ValueError:
return datetime.datetime.strptime(date, "%d %b %Y %H:%M:%S %z")

def read(self):
"Read the message (set flag '\Seen')"
Expand Down

0 comments on commit 869bfee

Please sign in to comment.