From cfacb77777fffedf6124576d376ac944fd0dc5e0 Mon Sep 17 00:00:00 2001 From: Cyberes Date: Wed, 6 Mar 2024 11:51:22 -0700 Subject: [PATCH] fix timestamp issues --- iarchiver/mail_conn.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/iarchiver/mail_conn.py b/iarchiver/mail_conn.py index 9f95682..8380bb2 100644 --- a/iarchiver/mail_conn.py +++ b/iarchiver/mail_conn.py @@ -4,7 +4,6 @@ import hashlib import imaplib import logging import sys -import time from email.header import decode_header from email.utils import parsedate_to_datetime from json import JSONEncoder @@ -69,9 +68,9 @@ class MailConnection: email_message = email.message_from_string(raw_email) date_header = email_message['Date'] if not date_header: - date_header = 0 - date = parsedate_to_datetime(date_header) - unix_timestamp = int(time.mktime(date.timetuple())) + date_header = 'Thu, 1 Jan 1970 00:00:00 +0000' + parsed_date = email.utils.parsedate_to_datetime(date_header) + unix_timestamp = int(parsed_date.timestamp()) from_addr = email_message['From'] to_addr = email_message['To']