def _get_message_date(self, message):
"""Finds date and time information for `message` and converts it to ISO-8601 format and UTC timezone.
"""
mail_date = message.get('Date', '').decode('utf-8')
if not mail_date:
"""The get_from() result always (so far as I have seen!) has the date string in the last 30 characters"""
mail_date = message.get_from().strip()[-30:]
datetime_tuple = email.utils.parsedate_tz(mail_date)
if datetime_tuple:
unix_time = email.utils.mktime_tz(datetime_tuple)
mail_date_iso8601 = datetime.utcfromtimestamp(unix_time).isoformat(' ')
else:
mail_date_iso8601 = ''
return mail_date_iso8601
评论列表
文章目录