You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

est2cet.rs 1.2KB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142
  1. use structopt::StructOpt;
  2. use chrono::prelude::*;
  3. /// convert EST time to CET
  4. ///
  5. /// examples:
  6. ///
  7. /// - est2cet 2pm
  8. ///
  9. /// - est2cet 1:30pm thu
  10. ///
  11. /// - est2cet 14:15 -d 2021-11-03
  12. ///
  13. #[derive(StructOpt, Debug)]
  14. #[structopt(author = env!("CARGO_PKG_AUTHORS"))]
  15. struct Opt {
  16. /// time to convert (%H:%M or %I[:%M]%p)
  17. #[structopt(value_name = "TIME")]
  18. time: String,
  19. /// optional: specify day of week the time lies, relative to today.
  20. ///
  21. /// this will always result in a DATE greater than or equal to
  22. /// today (in FROM TIMEZONE).
  23. ///
  24. /// example: if today is Thursday, Aug. 26, passing DAY OF WEEK "Friday"/"fri"
  25. /// will result in a DATE of Friday, Aug. 27.
  26. #[structopt(value_name = "DAY OF WEEK")]
  27. day: Option<String>,
  28. /// optional: specify date the time lies. defaults to today.
  29. ///
  30. /// when DAY OF WEEK argument is also specified, DAY OF WEEK will be picked relative
  31. /// to DATE (i.e. the next occuring instance of, on or following DATE).
  32. #[structopt(long, short, value_name = "DATE")]
  33. date: Option<NaiveDate>,
  34. }
  35. fn main() {
  36. let Opt { time, date, day } = Opt::from_args();
  37. tzconvert::convert("America/New_York", "Europe/Brussels", &time, day, date);
  38. }