Replies: 1 comment
|
Hi @Binilkks thanks for posting this issue. I understand the apparent "gap" in the API, but I'm not convinced yet that it needs to be filled. The current state explicitly reflects the fact that RFC2822 cannot be converted to a ZonedDateTime without additional information. The current approach is explicit and only a few more characters to type: # parsing
OffsetDateTime.parse_rfc2822(the_str).assume_tz('America/New_York')
# formatting
zdt.to_fixed_offset().format_rfc2822()This has the additional benefit of keeping the "what if the offset mismatches" handling contained to edit: additional note. Implementing RFC2822 on |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Feature Request: RFC 2822 support on
ZonedDateTimeProblem
Both
InstantandOffsetDateTimesupport RFC 2822 formatting and parsing:But
ZonedDateTime— despite being the most feature-rich datetime type — has no RFC 2822 support.Why it matters
RFC 2822 is used in:
Date:response headersDate:fieldsUsers working with
ZonedDateTimewho need to produce HTTP headers or email dates currently have to convert first:This breaks the ergonomic flow and is easy to forget.
Expected Behavior
For
format_rfc2822(), the offset at that point in time can be resolved from the IANA timezone. Forparse_rfc2822(), atzparameter would be needed to assign the IANA timezone (similar to howassume_tz()works).Consistency
format_rfc2822()parse_rfc2822()Filling this gap would make
ZonedDateTimeconsistent with the other exact-time types.All reactions