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) -> &str

Returns 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) -> f64

Returns 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) -> f64

Returns 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

Auto Trait Implementations

impl Freeze for TimeZoneLocation

impl RefUnwindSafe for TimeZoneLocation

impl Send for TimeZoneLocation

impl Sync for TimeZoneLocation

impl Unpin for TimeZoneLocation

impl UnsafeUnpin for TimeZoneLocation

impl UnwindSafe for TimeZoneLocation

Blanket Implementations

impl<T> Any for TimeZoneLocation where T: 'static + ?Sized,

impl<T> Borrow<T> for TimeZoneLocation where T: ?Sized,

impl<T> BorrowMut<T> for TimeZoneLocation where T: ?Sized,

impl<T> CloneToUninit for TimeZoneLocation where T: Clone,

impl<T> From<T> for TimeZoneLocation

impl<T> ToOwned for TimeZoneLocation where T: Clone,

impl<T, U> Into<U> for TimeZoneLocation where U: From<T>,

impl<T, U> TryFrom<U> for TimeZoneLocation where U: Into<T>,

impl<T, U> TryInto<U> for TimeZoneLocation where U: TryFrom<T>,