pub struct MetazoneCalculator { /* private fields */ }
Expand description

MetazoneCalculator uses data from the data provider to calculate metazone id.

Implementations

Constructor that loads data before calculating metazone id.

📚 Help choosing a constructor

⚠️ The bounds on this function may change over time, including in SemVer minor releases.
Examples
use icu::timezone::MetazoneCalculator;
use icu_locid::locale;

let mzc = MetazoneCalculator::try_new_unstable(&icu_testdata::unstable());

assert!(mzc.is_ok());

Creates a new instance using an AnyProvider.

For details on the behavior of this function, see: Self::try_new_unstable

📚 Help choosing a constructor

Enabled with the "serde" feature.

Creates a new instance using a BufferProvider.

For details on the behavior of this function, see: Self::try_new_unstable

📚 Help choosing a constructor

Calculate metazone id from timezone id and local datetime.

Examples
use icu::timezone::provider::{MetazoneId, TimeZoneBcp47Id};
use icu::timezone::MetazoneCalculator;
use icu_calendar::DateTime;
use icu_locid::locale;
use tinystr::tinystr;

let mzc = MetazoneCalculator::try_new_unstable(&icu_testdata::unstable())
    .expect("data exists");

assert_eq!(
    mzc.compute_metazone_from_time_zone(
        TimeZoneBcp47Id(tinystr!(8, "gugum")),
        &DateTime::try_new_iso_datetime(1969, 1, 1, 0, 0, 0).unwrap()
    ),
    None
);

assert_eq!(
    mzc.compute_metazone_from_time_zone(
        TimeZoneBcp47Id(tinystr!(8, "gugum")),
        &DateTime::try_new_iso_datetime(1970, 1, 1, 0, 0, 0).unwrap()
    ),
    Some(MetazoneId(tinystr!(4, "guam")))
);

assert_eq!(
    mzc.compute_metazone_from_time_zone(
        TimeZoneBcp47Id(tinystr!(8, "gugum")),
        &DateTime::try_new_iso_datetime(1975, 1, 1, 0, 0, 0).unwrap()
    ),
    Some(MetazoneId(tinystr!(4, "guam")))
);

assert_eq!(
    mzc.compute_metazone_from_time_zone(
        TimeZoneBcp47Id(tinystr!(8, "gugum")),
        &DateTime::try_new_iso_datetime(2000, 12, 22, 15, 0, 0).unwrap()
    ),
    Some(MetazoneId(tinystr!(4, "cham")))
);

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.