use structopt::StructOpt; use chrono::prelude::*; /// convert EST time to CET /// /// examples: /// /// - est2cet 2pm /// /// - est2cet 1:30pm thu /// /// - est2cet 14:15 -d 2021-11-03 /// #[derive(StructOpt, Debug)] #[structopt(author = env!("CARGO_PKG_AUTHORS"))] struct Opt { /// time to convert (%H:%M or %I[:%M]%p) #[structopt(value_name = "TIME")] time: String, /// optional: specify day of week the time lies, relative to today. /// /// this will always result in a DATE greater than or equal to /// today (in FROM TIMEZONE). /// /// example: if today is Thursday, Aug. 26, passing DAY OF WEEK "Friday"/"fri" /// will result in a DATE of Friday, Aug. 27. #[structopt(value_name = "DAY OF WEEK")] day: Option, /// optional: specify date the time lies. defaults to today. /// /// when DAY OF WEEK argument is also specified, DAY OF WEEK will be picked relative /// to DATE (i.e. the next occuring instance of, on or following DATE). #[structopt(long, short, value_name = "DATE")] date: Option, } fn main() { let Opt { time, date, day } = Opt::from_args(); tzconvert::convert("America/New_York", "Europe/Brussels", &time, day, date); }