mod args; mod err; mod git; mod time; use chrono::prelude::*; use chrono_tz::Tz; use clap::Parser; fn main() { let cli = args::Cli::parse(); println!("{:#?}", cli); let tz = cli .timezone .unwrap_or_else(|| get_local_timezone().expect("Could not get local timezone")); let start_time = tz.from_local_datetime(&cli.start_time).unwrap(); let end_time = if let Some(time) = cli.end_time { tz.from_local_datetime(&time).unwrap() } else { Utc::now().with_timezone(&tz) }; println!( "start_time = {:#?}, end_time = {:#?}, tz = {:#?}", start_time, end_time, tz ) } fn get_local_timezone() -> Result { match iana_time_zone::get_timezone() { Ok(tz_string) => tz_string.parse(), Err(e) => Err(e.to_string()), } }