#[non_exhaustive]pub enum Format {
Rfc3339,
Rfc9557,
Iso8601,
Rfc2822,
HttpDate,
DateOnly,
TimeOnly,
}Expand description
A well-known datetime representation.
§Representability
DateTime::format is infallible and best effort: it can emit a
non-conforming string for out-of-domain values (for example -0001 for a
negative year, or +00:19:32 for a historical offset with a seconds
component). Use DateTime::try_format or DateTime::format_to when
the value must be strictly valid for the requested format; both reject a
year outside 0000..=9999 (except for TimeOnly) and, for Rfc3339,
Rfc9557, Iso8601 and Rfc2822, an offset with a seconds component.
TimeOnly is always valid.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Rfc3339
RFC 3339 / ISO 8601, for example 2006-01-02T15:04:05Z or
2006-01-02T15:04:05+07:00.
Rfc9557
RFC 3339 plus an RFC 9557 time zone annotation, for example
2006-01-02T15:04:05-05:00[America/New_York].
Iso8601
RFC 3339, except that a zero offset is written as +00:00 rather than
Z.
Rfc2822
RFC 2822 (email) date, for example
Mon, 02 Jan 2006 15:04:05 +0000.
HttpDate
HTTP IMF-fixdate, for example Mon, 02 Jan 2006 15:04:05 GMT.
The value is always converted to UTC.
DateOnly
Just the date, for example 2006-01-02.
TimeOnly
Just the time, for example 15:04:05 (with fractional seconds when
they are non-zero).