expression
Chrono NaiveDate: calendar dates
A date represents a calendar day without an hour or time zone. Chrono uses a proleptic Gregorian calendar. The checked constructor rejects impossible dates. This example uses external crates; see the staged Cargo manifest. Expected stdout (not executed): 2024-02-29 true Common mistake: Treating every February as having 29 days.
Formal Syntax & Structure
rust syntaxrust
NaiveDate::from_ymd_opt(year, month, day) -> Option<NaiveDate>Working Example
Example Snippetrust
fn main() { use chrono::NaiveDate; let leap = NaiveDate::from_ymd_opt(2024, 2, 29).unwrap(); println!("{} {}", leap, NaiveDate::from_ymd_opt(2025, 2, 29).is_none());}