Module rfc2822
dep_jiff
and alloc
only.Expand description
Support for printing and parsing instants using the RFC 2822 datetime format.
RFC 2822 is most commonly found when dealing with email messages.
Since RFC 2822 only supports specifying a complete instant in time, the parser
and printer in this module only use Zoned
and Timestamp
. If you need
inexact time, you can get it from Zoned
via Zoned::datetime
.
§Incomplete support
The RFC 2822 support in this crate is technically incomplete. Specifically, it does not support parsing comments within folding whitespace. It will parse comments after the datetime itself (including nested comments). See Issue #39 for an example. If you find a real world use case for parsing comments within whitespace at any point in the datetime string, please file an issue. That is, the main reason it isn’t currently supported is because it didn’t seem worth the implementation complexity to account for it. But if there are real world use cases that need it, then that would be sufficient justification for adding it.
RFC 2822 support should otherwise be complete, including support for parsing obselete offsets.
§Warning
The RFC 2822 format only supports writing a precise instant in time
expressed via a time zone offset. It does not support serializing
the time zone itself. This means that if you format a zoned datetime
in a time zone like America/New_York
and then deserialize it, the
zoned datetime you get back will be a “fixed offset” zoned datetime.
This in turn means it will not perform daylight saving time safe
arithmetic.
Basically, you should use the RFC 2822 format if it’s required (for example, when dealing with email). But you should not choose it as a general interchange format for new applications.