Skip to content

Commit 3e27a86

Browse files
authored
fix(inbox): RFC 2822 dates parsing (#616)
1 parent 2efee77 commit 3e27a86

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

sources/inbox/helpers.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import hashlib
44
from email.message import Message
55
from email.header import decode_header, make_header
6+
from email.utils import parsedate_to_datetime
67
from time import mktime
78
from typing import Any, Dict, Iterator, Optional, Sequence, Tuple
89

@@ -87,7 +88,9 @@ def extract_email_info(msg: Message, include_body: bool = False) -> Dict[str, An
8788
Dict[str, Any]: The email information.
8889
"""
8990
email_data = dict(msg)
90-
email_data["Date"] = pendulum.parse(msg["Date"], strict=False)
91+
dt = parsedate_to_datetime(msg["Date"])
92+
dt_pendulum = pendulum.instance(dt)
93+
email_data["Date"] = dt_pendulum
9194
email_data["content_type"] = msg.get_content_type()
9295
if include_body:
9396
email_data["body"] = get_email_body(msg)

0 commit comments

Comments
 (0)