advent_of_code_data/utils.rs
1use crate::Year;
2
3/// Get the time and date when the first puzzle will unlock for the given year.
4pub fn get_puzzle_unlock_time(for_year: Year) -> chrono::DateTime<chrono::Utc> {
5 use chrono::{NaiveDate, TimeZone};
6 use chrono_tz::US::Eastern;
7
8 let unlock_dt = NaiveDate::from_ymd_opt(for_year.into(), 12, 1)
9 .unwrap()
10 .and_time(Default::default());
11
12 Eastern
13 .from_local_datetime(&unlock_dt)
14 .unwrap()
15 .with_timezone(&chrono::Utc)
16}