Expand description
Easy mapping between IATA airport codes and timezones + cooridnates.
Provides mappings between IATA airport codes like “LHR” / “SFO” to non-abbreviated timezone name like “Europe/London”. Also includes ability to get DateTime object in the given time zone for convience.
Actual mapping has been assambled from various sources available online and spot check validated of around 400 locations.
Examples
Fetch time zone string of the LHR (London) airport.
use airports::Airports;
fn main() {
let db = Airports::new();
println!("lhr: {:?}", db.get_tz_name("lhr"));
println!("LHR: {:?}", db.get_tz_name("LHR"));
println!("SOMETHING: {:?}", db.get_tz_name("SOMETHING"));
}
Which produces the following output:
lhr: Some("Europe/London")
LHR: Some("Europe/London")
SOMETHING: None
The get_tz function returns Option on Tz allowing easy check of time in the given airport location. See examples/ for more details.
let db = Airports::new();
let x: DateTime<Tz>= Utc::now().with_timezone(&db.get_tz("SFO").unwrap());
println!("Time in SFO: {}", x);
Time in SFO: 2022-06-28 08:27:11.605433 PDT