Crate to map airport IATA code to timezone
``` use airports::Airports;
fn main() { let db = Airports::new(); println!("lhr: {:?}", db.gettzname("lhr")); println!("LHR: {:?}", db.gettzname("LHR")); println!("SOMETHING: {:?}", db.gettzname("SOMETHING")); } ```
Prints out
lhr: Some("Europe/London")
LHR: Some("Europe/London")
SOMETHING: None
It is also possible to directly map the IATA code to IANA time zone and get chronotz Tz wrapped in an option for convinience. ``` use airports::Airports; use chrono::{DateTime, TimeZone, Utc}; use chronotz::Tz;
fn main() { let db = Airports::new(); println!("SFO timezone: {:?}", db.gettzname("sfo").unwrap());
match db.get_tz("SFO") {
Some(t) => {
let x: DateTime<Tz> = Utc::now().with_timezone(&t);
println!("Current time in SFO: {}", x);
}
None => println!("Not found!"),
}
}
SFO timezone: "America/Los_Angeles"
Current time in SFO: 2022-06-28 08:31:43.613397 PDT
```