expression
Chrono UTC construction
Build a fixed UTC instant using checked calendar fields. UTC has no daylight-saving transitions. Import TimeZone for this constructor. This example uses external crates; see the staged Cargo manifest. Expected stdout (not executed): 2025-01-01T00:00:00+00:00 Common mistake: Using machine-local time for deterministic tests.
Formal Syntax & Structure
rust syntaxrust
Utc.with_ymd_and_hms(y, m, d, h, min, s).single()Working Example
Example Snippetrust
fn main() { use chrono::{TimeZone, Utc}; let t = Utc.with_ymd_and_hms(2025, 1, 1, 0, 0, 0).single().unwrap(); println!("{}", t.to_rfc3339());}