pub struct UtcOffset {
hours: RangedI8<-25, 25>,
minutes: RangedI8<{ _ }, { _ }>,
seconds: RangedI8<{ _ }, { _ }>,
}
Expand description
An offset from UTC.
This struct can store values up to ±25:59:59. If you need support outside this range, please file an issue with your use case.
Fields§
§hours: RangedI8<-25, 25>
§minutes: RangedI8<{ _ }, { _ }>
§seconds: RangedI8<{ _ }, { _ }>
Implementations§
source§impl UtcOffset
impl UtcOffset
sourcepub const fn from_hms(
hours: i8,
minutes: i8,
seconds: i8,
) -> Result<Self, ComponentRange>
pub const fn from_hms( hours: i8, minutes: i8, seconds: i8, ) -> Result<Self, ComponentRange>
Create a UtcOffset
representing an offset by the number of hours, minutes, and seconds
provided.
The sign of all three components should match. If they do not, all smaller components will have their signs flipped.
sourcepub(crate) const fn from_hms_ranged_unchecked(
hours: RangedI8<-25, 25>,
minutes: RangedI8<{ _ }, { _ }>,
seconds: RangedI8<{ _ }, { _ }>,
) -> Self
pub(crate) const fn from_hms_ranged_unchecked( hours: RangedI8<-25, 25>, minutes: RangedI8<{ _ }, { _ }>, seconds: RangedI8<{ _ }, { _ }>, ) -> Self
Create a UtcOffset
representing an offset of the hours, minutes, and seconds provided. All
three parameters must have the same sign.
While the signs of the parameters are required to match, this is not a safety invariant.
sourcepub(crate) const fn from_hms_ranged(
hours: RangedI8<-25, 25>,
minutes: RangedI8<{ _ }, { _ }>,
seconds: RangedI8<{ _ }, { _ }>,
) -> Self
pub(crate) const fn from_hms_ranged( hours: RangedI8<-25, 25>, minutes: RangedI8<{ _ }, { _ }>, seconds: RangedI8<{ _ }, { _ }>, ) -> Self
Create a UtcOffset
representing an offset by the number of hours, minutes, and seconds
provided.
The sign of all three components should match. If they do not, all smaller components will have their signs flipped.
sourcepub const fn from_whole_seconds(seconds: i32) -> Result<Self, ComponentRange>
pub const fn from_whole_seconds(seconds: i32) -> Result<Self, ComponentRange>
sourcepub(crate) const fn from_whole_seconds_ranged(
seconds: RangedI32<{ _ }, { _ }>,
) -> Self
pub(crate) const fn from_whole_seconds_ranged( seconds: RangedI32<{ _ }, { _ }>, ) -> Self
Create a UtcOffset
representing an offset by the number of seconds provided.
assert_eq!(
UtcOffset::from_whole_seconds_ranged(RangedI32::new_static::<3_723>()).as_hms(),
(1, 2, 3)
);
sourcepub const fn whole_hours(self) -> i8
pub const fn whole_hours(self) -> i8
sourcepub const fn whole_minutes(self) -> i16
pub const fn whole_minutes(self) -> i16
sourcepub const fn minutes_past_hour(self) -> i8
pub const fn minutes_past_hour(self) -> i8
sourcepub const fn whole_seconds(self) -> i32
pub const fn whole_seconds(self) -> i32
sourcepub const fn seconds_past_minute(self) -> i8
pub const fn seconds_past_minute(self) -> i8
sourcepub const fn is_positive(self) -> bool
pub const fn is_positive(self) -> bool
sourcepub const fn is_negative(self) -> bool
pub const fn is_negative(self) -> bool
sourcepub fn local_offset_at(
datetime: OffsetDateTime,
) -> Result<Self, IndeterminateOffset>
pub fn local_offset_at( datetime: OffsetDateTime, ) -> Result<Self, IndeterminateOffset>
sourcepub fn current_local_offset() -> Result<Self, IndeterminateOffset>
pub fn current_local_offset() -> Result<Self, IndeterminateOffset>
source§impl UtcOffset
impl UtcOffset
sourcepub fn format_into(
self,
output: &mut impl Write,
format: &(impl Formattable + ?Sized),
) -> Result<usize, Format>
pub fn format_into( self, output: &mut impl Write, format: &(impl Formattable + ?Sized), ) -> Result<usize, Format>
Format the UtcOffset
using the provided format description.
sourcepub fn format(
self,
format: &(impl Formattable + ?Sized),
) -> Result<String, Format>
pub fn format( self, format: &(impl Formattable + ?Sized), ) -> Result<String, Format>
Format the UtcOffset
using the provided format description.
Trait Implementations§
source§impl<'a> Deserialize<'a> for UtcOffset
impl<'a> Deserialize<'a> for UtcOffset
source§fn deserialize<D: Deserializer<'a>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'a>>(deserializer: D) -> Result<Self, D::Error>
source§impl Ord for UtcOffset
impl Ord for UtcOffset
source§impl PartialOrd for UtcOffset
impl PartialOrd for UtcOffset
source§impl SmartDisplay for UtcOffset
impl SmartDisplay for UtcOffset
source§type Metadata = UtcOffsetMetadata
type Metadata = UtcOffsetMetadata
source§fn metadata(&self, _: FormatterOptions) -> Metadata<'_, Self>
fn metadata(&self, _: FormatterOptions) -> Metadata<'_, Self>
impl Copy for UtcOffset
impl Eq for UtcOffset
impl StructuralPartialEq for UtcOffset
Auto Trait Implementations§
impl Freeze for UtcOffset
impl RefUnwindSafe for UtcOffset
impl Send for UtcOffset
impl Sync for UtcOffset
impl Unpin for UtcOffset
impl UnwindSafe for UtcOffset
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)