From e0f52a6287c75d36a09b210373e5d514af861108 Mon Sep 17 00:00:00 2001 From: Arie Bovenberg Date: Sat, 16 Nov 2024 22:20:11 +0100 Subject: [PATCH] add note about RFC2822 parsing --- CHANGELOG.rst | 2 ++ pysrc/whenever/_pywhenever.py | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c2f0f20..0c464b0 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -14,6 +14,8 @@ - Parsing UTC offsets with out-of-range minute components (e.g. ``06:79``) now raises the expected parsing failure. +- Note in ``parse_rfc2822()`` docstring that it doesn't (yet) validate the input, + due to limitations in the underlying parser. 0.6.12 (2024-11-08) ------------------- diff --git a/pysrc/whenever/_pywhenever.py b/pysrc/whenever/_pywhenever.py index 41a3d95..15be951 100644 --- a/pysrc/whenever/_pywhenever.py +++ b/pysrc/whenever/_pywhenever.py @@ -3081,9 +3081,12 @@ def parse_rfc2822(cls, s: str, /) -> Instant: Important --------- - Nonzero offsets will not be implicitly converted to UTC. - Use ``OffsetDateTime.parse_rfc2822()`` if you'd like to - parse an RFC 2822 string with a nonzero offset. + - This function parses, but **does not validate** the input (yet). + This is due to the limitations of the underlying + function ``email.utils.parsedate_to_datetime()``. + - Nonzero offsets will not be implicitly converted to UTC. + Use ``OffsetDateTime.parse_rfc2822()`` if you'd like to + parse an RFC 2822 string with a nonzero offset. """ # FUTURE: disallow +0000 parsed = _parse_rfc2822(s) @@ -3656,9 +3659,12 @@ def parse_rfc2822(cls, s: str, /) -> OffsetDateTime: Warning ------- - The offset ``-0000`` has special meaning in RFC 2822, - indicating a UTC time with unknown local offset. - Thus, it cannot be parsed to an :class:`OffsetDateTime`. + - This function parses, but **does not validate** the input (yet). + This is due to the limitations of the underlying + function ``email.utils.parsedate_to_datetime()``. + - The offset ``-0000`` has special meaning in RFC 2822, + indicating a UTC time with unknown local offset. + Thus, it cannot be parsed to an :class:`OffsetDateTime`. """ parsed = _parse_rfc2822(s) if parsed.tzinfo is None: