use structopt::StructOpt; use chrono::prelude::*; /// convert CET time to EST /// /// examples: /// /// - cet2est 2pm /// /// - cet2est 1:30pm thu /// /// - cet2est 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("Europe/Brussels", "America/New_York", &time, day, date); }