pub struct VariantOffsetsCalculatorBorrowed<'a> { /* private fields */ }๐Deprecated since 2.1.0: this API is a bad approximation of a time zone database
Expand description
The borrowed version of a VariantOffsetsCalculator
Implementationsยง
Sourceยงimpl VariantOffsetsCalculatorBorrowed<'static>
impl VariantOffsetsCalculatorBorrowed<'static>
Sourcepub const fn new() -> VariantOffsetsCalculatorBorrowed<'static>
pub const fn new() -> VariantOffsetsCalculatorBorrowed<'static>
Constructs a VariantOffsetsCalculatorBorrowed using compiled data.
โจ Enabled with the compiled_data Cargo feature.
Sourcepub fn static_to_owned(&self) -> VariantOffsetsCalculator
pub fn static_to_owned(&self) -> VariantOffsetsCalculator
Cheaply converts a VariantOffsetsCalculatorBorrowed<'static> into a VariantOffsetsCalculator.
Note: Due to branching and indirection, using VariantOffsetsCalculator might inhibit some
compile-time optimizations that are possible with VariantOffsetsCalculatorBorrowed.
Sourceยงimpl VariantOffsetsCalculatorBorrowed<'_>
impl VariantOffsetsCalculatorBorrowed<'_>
Sourcepub fn compute_offsets_from_time_zone_and_name_timestamp(
&self,
time_zone_id: TimeZone,
timestamp: ZoneNameTimestamp,
) -> Option<VariantOffsets>
pub fn compute_offsets_from_time_zone_and_name_timestamp( &self, time_zone_id: TimeZone, timestamp: ZoneNameTimestamp, ) -> Option<VariantOffsets>
Calculate zone offsets from timezone and local datetime.
ยงExamples
use icu::calendar::Date;
use icu::locale::subtags::subtag;
use icu::time::zone::UtcOffset;
use icu::time::zone::VariantOffsetsCalculator;
use icu::time::zone::ZoneNameTimestamp;
use icu::time::Time;
use icu::time::TimeZone;
let zoc = VariantOffsetsCalculator::new();
// America/Denver observes DST
let offsets = zoc
.compute_offsets_from_time_zone_and_name_timestamp(
TimeZone(subtag!("usden")),
ZoneNameTimestamp::far_in_future(),
)
.unwrap();
assert_eq!(
offsets.standard,
UtcOffset::try_from_seconds(-7 * 3600).unwrap()
);
assert_eq!(
offsets.daylight,
Some(UtcOffset::try_from_seconds(-6 * 3600).unwrap())
);
// America/Phoenix does not
let offsets = zoc
.compute_offsets_from_time_zone_and_name_timestamp(
TimeZone(subtag!("usphx")),
ZoneNameTimestamp::far_in_future(),
)
.unwrap();
assert_eq!(
offsets.standard,
UtcOffset::try_from_seconds(-7 * 3600).unwrap()
);
assert_eq!(offsets.daylight, None);Trait Implementationsยง
Sourceยงimpl<'a> Debug for VariantOffsetsCalculatorBorrowed<'a>
impl<'a> Debug for VariantOffsetsCalculatorBorrowed<'a>
Sourceยงimpl Default for VariantOffsetsCalculatorBorrowed<'static>
impl Default for VariantOffsetsCalculatorBorrowed<'static>
Sourceยงfn default() -> VariantOffsetsCalculatorBorrowed<'static>
fn default() -> VariantOffsetsCalculatorBorrowed<'static>
Returns the โdefault valueโ for a type. Read more
Auto Trait Implementationsยง
impl<'a> Freeze for VariantOffsetsCalculatorBorrowed<'a>
impl<'a> RefUnwindSafe for VariantOffsetsCalculatorBorrowed<'a>
impl<'a> Send for VariantOffsetsCalculatorBorrowed<'a>
impl<'a> Sync for VariantOffsetsCalculatorBorrowed<'a>
impl<'a> Unpin for VariantOffsetsCalculatorBorrowed<'a>
impl<'a> UnwindSafe for VariantOffsetsCalculatorBorrowed<'a>
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
Sourceยงimpl<T> IntoEither for T
impl<T> IntoEither for T
Sourceยงfn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSourceยงfn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more