expression

Chrono-TZ nonexistent local time

During a forward clock transition some local clock readings do not occur. A scheduler should reject the input or apply a documented adjustment policy instead of guessing. This example uses external crates; see the staged Cargo manifest. Expected stdout (not executed): true Common mistake: Unwrapping a local time conversion that may fail during a DST gap.

Formal Syntax & Structure

rust syntaxrust
TimeZone::from_local_datetime(&naive) -> LocalResult<_>

Working Example

Example Snippetrust
fn main() {    use chrono::{LocalResult, NaiveDate, TimeZone};    use chrono_tz::Europe::Paris;    let wall = NaiveDate::from_ymd_opt(2024, 3, 31).unwrap().and_hms_opt(2, 30, 0).unwrap();    println!("{}", matches!(Paris.from_local_datetime(&wall), LocalResult::None));}
Rust Reference