fix timestamp issues
This commit is contained in:
parent
f9624f81e9
commit
cfacb77777
|
@ -4,7 +4,6 @@ import hashlib
|
||||||
import imaplib
|
import imaplib
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
import time
|
|
||||||
from email.header import decode_header
|
from email.header import decode_header
|
||||||
from email.utils import parsedate_to_datetime
|
from email.utils import parsedate_to_datetime
|
||||||
from json import JSONEncoder
|
from json import JSONEncoder
|
||||||
|
@ -69,9 +68,9 @@ class MailConnection:
|
||||||
email_message = email.message_from_string(raw_email)
|
email_message = email.message_from_string(raw_email)
|
||||||
date_header = email_message['Date']
|
date_header = email_message['Date']
|
||||||
if not date_header:
|
if not date_header:
|
||||||
date_header = 0
|
date_header = 'Thu, 1 Jan 1970 00:00:00 +0000'
|
||||||
date = parsedate_to_datetime(date_header)
|
parsed_date = email.utils.parsedate_to_datetime(date_header)
|
||||||
unix_timestamp = int(time.mktime(date.timetuple()))
|
unix_timestamp = int(parsed_date.timestamp())
|
||||||
|
|
||||||
from_addr = email_message['From']
|
from_addr = email_message['From']
|
||||||
to_addr = email_message['To']
|
to_addr = email_message['To']
|
||||||
|
|
Loading…
Reference in New Issue