use structopt::StructOpt; use chrono::prelude::*; /// timezone converter /// /// Examples: /// /// - tzconvert CET EST 2pm /// /// - tzconvert Africa/Timbuktu America/Jamaica 18:30 --date 2021-11-03 /// #[derive(StructOpt, Debug)] #[structopt(author = env!("CARGO_PKG_AUTHORS"))] struct Opt { /// originating time zone #[structopt(value_name = "FROM TIMEZONE")] from: String, /// destination time zone #[structopt(value_name = "TO TIMEZONE")] to: String, /// time to convert (HH:MM or HH[:MM]am/HH[:MM]pm) #[structopt(value_name = "TIME")] time: String, /// specify the date on which the time lies; defaults to today #[structopt(long, short)] date: Option, } fn main() { let Opt { from, to, time, date } = Opt::from_args(); tzconvert::convert(&from, &to, &time, date); }