pub struct VariantOffsetsCalculatorBorrowed<'a> { /* private fields */ }
Expand description
The borrowed version of a VariantOffsetsCalculator
Implementations§
Source§impl VariantOffsetsCalculatorBorrowed<'static>
impl VariantOffsetsCalculatorBorrowed<'static>
Sourcepub const fn new() -> Self
pub const fn new() -> Self
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(
&self,
time_zone_id: TimeZone,
dt: (Date<Iso>, Time),
) -> Option<VariantOffsets>
pub fn compute_offsets_from_time_zone( &self, time_zone_id: TimeZone, dt: (Date<Iso>, Time), ) -> Option<VariantOffsets>
Calculate zone offsets from timezone and local datetime.
§Examples
use icu::calendar::Date;
use icu::time::zone::UtcOffset;
use icu::time::zone::VariantOffsetsCalculator;
use icu::time::Time;
use icu::time::TimeZone;
use tinystr::tinystr;
let zoc = VariantOffsetsCalculator::new();
// America/Denver observes DST
let offsets = zoc
.compute_offsets_from_time_zone(
TimeZone(tinystr!(8, "usden")),
(Date::try_new_iso(2024, 1, 1).unwrap(), Time::midnight()),
)
.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(
TimeZone(tinystr!(8, "usphx")),
(Date::try_new_iso(2024, 1, 1).unwrap(), Time::midnight()),
)
.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>
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