Skip to content

Commit

Permalink
Merge pull request #205 from AT0myks/preserve-timezone
Browse files Browse the repository at this point in the history
Preserve timezone info in date parsing
  • Loading branch information
martinrusev authored Aug 5, 2021
2 parents 5bda8cf + 584cb23 commit 76763d5
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions imbox/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,7 @@ def parse_email(raw_email, policy=None):
'Value': value})

if parsed_email.get('date'):
timetuple = email.utils.parsedate(parsed_email['date'])
parsed_date = datetime.fromtimestamp(time.mktime(timetuple)) \
if timetuple else None
parsed_email['parsed_date'] = parsed_date
parsed_email['parsed_date'] = email.utils.parsedate_to_datetime(parsed_email['date'])

logger.info("Downloaded and parsed mail '{}' with {} attachments".format(
parsed_email.get('subject'), len(parsed_email.get('attachments'))))
Expand Down

0 comments on commit 76763d5

Please sign in to comment.