From b46a4082a427ca456c4c31fe03520dd0a02690a1 Mon Sep 17 00:00:00 2001 From: Joscha Feth Date: Tue, 13 May 2025 21:15:20 +1000 Subject: [PATCH] fix(inbox): RFC 2822 dates parsing --- sources/inbox/helpers.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sources/inbox/helpers.py b/sources/inbox/helpers.py index 3fde6b598..188354222 100644 --- a/sources/inbox/helpers.py +++ b/sources/inbox/helpers.py @@ -3,6 +3,7 @@ import hashlib from email.message import Message from email.header import decode_header, make_header +from email.utils import parsedate_to_datetime from time import mktime from typing import Any, Dict, Iterator, Optional, Sequence, Tuple @@ -87,7 +88,9 @@ def extract_email_info(msg: Message, include_body: bool = False) -> Dict[str, An Dict[str, Any]: The email information. """ email_data = dict(msg) - email_data["Date"] = pendulum.parse(msg["Date"], strict=False) + dt = parsedate_to_datetime(msg["Date"]) + dt_pendulum = pendulum.instance(dt) + email_data["Date"] = dt_pendulum email_data["content_type"] = msg.get_content_type() if include_body: email_data["body"] = get_email_body(msg)