use chrono::{NaiveDate, Utc};
/// Checks if a given year, month, and day are strictly in the future compared to today.
/// Returns Some(true) if in the future, Some(false) otherwise, or None if the date is invalid.
fn is_date_in_future(year: i32, month: u32, day: u32) -> Option<bool> {
// 1. Construct and validate the target date safely
let target_date = NaiveDate::from_ymd_opt(year, month, day)?;
// 2. Get today's date in UTC (ignoring time components for a clean calendar comparison)
let today = Utc::now().date_naive();
// 3. Compare dates directly using standard comparison operators
Some(target_date > today)
}
fn main() {
let test_year = 2035;
let test_month = 6;
let test_day = 15;
println!("Checking date: {:04}-{:02}-{:02}", test_year, test_month, test_day);
match is_date_in_future(test_year, test_month, test_day) {
Some(true) => println!("Result: The date is in the FUTURE."),
Some(false) => println!("Result: The date is NOT in the future."),
None => println!("Error: Invalid calendar date provided."),
}
}
/*
run:
Checking date: 2035-06-15
Result: The date is in the FUTURE.
*/