1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//! 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
//! ```
//#![warn(missing_docs)]
use Tz;
use BTreeMap;