pub struct Airports { /* private fields */ }
Implementations§
Source§impl Airports
impl Airports
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
More examples
examples/sfo.rs (line 6)
5 6 7 8 9 10 11 12 13 14 15 16
fn main() {
let db = Airports::new();
println!("SFO timezone: {:?}", db.get_tz_name("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!"),
}
}
Sourcepub fn get_tz_name(&self, code: &str) -> Option<&String>
pub fn get_tz_name(&self, code: &str) -> Option<&String>
Returns an Option on String, with String containing the timezone name, or None if mapping not found.
§Example
let lhr_timezone = db.get_tz_name("LHR");
Examples found in repository?
More examples
examples/sfo.rs (line 7)
5 6 7 8 9 10 11 12 13 14 15 16
fn main() {
let db = Airports::new();
println!("SFO timezone: {:?}", db.get_tz_name("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!"),
}
}
Sourcepub fn get_tz(&self, code: &str) -> Option<Tz>
pub fn get_tz(&self, code: &str) -> Option<Tz>
Returns an Option on Tz (from chrono_tz) for given IATA airport code. This can be then passed to chrono/DataTime to get time using specific time zone.
§Example
use airports::Airports; use chrono::{DateTime, Utc}; use chrono_tz::Tz;
fn main() {
let db = Airports::new();
let x: DateTime
Examples found in repository?
More examples
examples/sfo.rs (line 9)
5 6 7 8 9 10 11 12 13 14 15 16
fn main() {
let db = Airports::new();
println!("SFO timezone: {:?}", db.get_tz_name("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!"),
}
}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Airports
impl RefUnwindSafe for Airports
impl Send for Airports
impl Sync for Airports
impl Unpin for Airports
impl UnwindSafe for Airports
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more