Skip to content

Commit

Permalink
add note about RFC2822 parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
ariebovenberg committed Nov 16, 2024
1 parent 9f23abd commit e0f52a6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
-------------------
Expand Down
18 changes: 12 additions & 6 deletions pysrc/whenever/_pywhenever.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit e0f52a6

Please sign in to comment.