Struct TimeZoneLocation
pub struct TimeZoneLocation { /* private fields */ }
The geographical location corresponding to a primary time zone identifier.
This can be retrieved for a time zone via TimeZone::location.
Example
use jiff::tz::TimeZone;
# if TimeZone::get("Asia/Calcutta").is_err() { return Ok(()) };
let tz = TimeZone::get("Europe/Copenhagen")?;
let loc = tz.location().unwrap();
assert_eq!(loc.country(), "DK");
let tz = TimeZone::get("EuRoPe/BeRlIn")?;
let loc = tz.location().unwrap();
assert_eq!(loc.country(), "DE");
let tz = TimeZone::get("asia/calcutta")?;
let loc = tz.location().unwrap();
assert_eq!(loc.country(), "IN");
# Ok::<(), Box<dyn std::error::Error>>(())
Implementations
impl TimeZoneLocation
const fn country(&self) -> &strReturns the ISO 3166 country code for the corresponding time zone.
Example
use jiff::tz::TimeZone; # if TimeZone::get("Asia/Calcutta").is_err() { return Ok(()) }; let tz = TimeZone::get("Asia/Calcutta")?; let loc = tz.location().unwrap(); assert_eq!(loc.country(), "IN"); # Ok::<(), Box<dyn std::error::Error>>(())const fn latitude(&self) -> f64Returns the latitude coordinate for the corresponding time zone.
Example
use jiff::tz::TimeZone; # if TimeZone::get("Asia/Calcutta").is_err() { return Ok(()) }; let tz = TimeZone::get("Asia/Calcutta")?; let loc = tz.location().unwrap(); assert_eq!(loc.latitude(), 22.533333333333335); # Ok::<(), Box<dyn std::error::Error>>(())const fn longitude(&self) -> f64Returns the longitude coordinate for the corresponding time zone.
Example
use jiff::tz::TimeZone; # if TimeZone::get("Asia/Calcutta").is_err() { return Ok(()) }; let tz = TimeZone::get("Asia/Calcutta")?; let loc = tz.location().unwrap(); assert_eq!(loc.longitude(), 88.36666666666666); # Ok::<(), Box<dyn std::error::Error>>(())
Trait Implementations
impl Clone for TimeZoneLocation
fn clone(&self) -> Self
impl Copy for TimeZoneLocation
impl Debug for TimeZoneLocation
fn fmt(&self, f: &mut Formatter<'_>) -> Result