1 2 3 4 5 6 7 8 9 10 11 12 13 14
use chrono::NaiveDate; #[derive(Debug)] pub struct DateTime { inner: NaiveDate, } impl DateTime { pub fn from_ymd_opt(year: i32, month: u32, day: u32) -> Option<DateTime> { Some(DateTime { inner: NaiveDate::from_ymd_opt(year, month, day)?, }) } }