expression
time crate RFC 3339 round trip
Use the predefined RFC 3339 format for interchange rather than relying on a general Display implementation. The output can normalize syntax; compare the instant and required metadata. This example uses external crates; see the staged Cargo manifest. Expected stdout (not executed): 2025-06-01T12:00:00+02:00 Common mistake: Expecting a parse-and-format cycle to preserve every original textual detail.
Formal Syntax & Structure
rust syntaxrust
OffsetDateTime::parse(input, &Rfc3339); format(&Rfc3339)Working Example
Example Snippetrust
fn main() { use time::{OffsetDateTime, format_description::well_known::Rfc3339}; let t = OffsetDateTime::parse("2025-06-01T12:00:00+02:00", &Rfc3339).unwrap(); println!("{}", t.format(&Rfc3339).unwrap());}