#[repr(C)]pub struct UtcOffset {
seconds: ri8<{ _ }, { _ }>,
minutes: ri8<{ _ }, { _ }>,
hours: ri8<-25, 25>,
}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§
§seconds: ri8<{ _ }, { _ }>§minutes: ri8<{ _ }, { _ }>§hours: ri8<-25, 25>Implementations§
Source§impl UtcOffset
impl UtcOffset
Sourcepub(crate) const fn as_u32_for_equality(self) -> u32
pub(crate) const fn as_u32_for_equality(self) -> u32
Provide a representation of the UtcOffset as a i32. This value can be used for equality,
and hashing. This value is not suitable for ordering; use as_i32_for_comparison instead.
Sourceconst fn as_i32_for_comparison(self) -> i32
const fn as_i32_for_comparison(self) -> i32
Provide a representation of the UtcOffset as a i32. This value can be used for ordering.
While it is suitable for equality, as_u32_for_equality is preferred for performance
reasons.
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: ri8<-25, 25>,
minutes: ri8<{ _ }, { _ }>,
seconds: ri8<{ _ }, { _ }>,
) -> Self
pub(crate) const fn from_hms_ranged_unchecked( hours: ri8<-25, 25>, minutes: ri8<{ _ }, { _ }>, seconds: ri8<{ _ }, { _ }>, ) -> 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: ri8<-25, 25>,
minutes: ri8<{ _ }, { _ }>,
seconds: ri8<{ _ }, { _ }>,
) -> Self
pub(crate) const fn from_hms_ranged( hours: ri8<-25, 25>, minutes: ri8<{ _ }, { _ }>, seconds: ri8<{ _ }, { _ }>, ) -> 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: ri32<{ _ }, { _ }>,
) -> Self
pub(crate) const fn from_whole_seconds_ranged( seconds: ri32<{ _ }, { _ }>, ) -> 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(crate) const fn as_hms_ranged(
self,
) -> (ri8<-25, 25>, ri8<{ _ }, { _ }>, ri8<{ _ }, { _ }>)
pub(crate) const fn as_hms_ranged( self, ) -> (ri8<-25, 25>, ri8<{ _ }, { _ }>, ri8<{ _ }, { _ }>)
Obtain the UTC offset as its hours, minutes, and seconds. The sign of all three components will always match. A positive value indicates an offset to the east; a negative to the west.
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 + ?Sized),
format: &(impl Formattable + ?Sized),
) -> Result<usize, Format>
pub fn format_into( self, output: &mut (impl Write + ?Sized), 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.
Source§impl UtcOffset
impl UtcOffset
Source§impl UtcOffset
impl UtcOffset
Sourcepub(crate) const DISPLAY_BUFFER_SIZE: usize = 9
pub(crate) const DISPLAY_BUFFER_SIZE: usize = 9
The maximum number of bytes that the fmt_into_buffer method will write, which is also used
for the Display implementation.
Sourcepub(crate) const fn fmt_into_buffer(
self,
buf: &mut [MaybeUninit<u8>; 9],
) -> usize
pub(crate) const fn fmt_into_buffer( self, buf: &mut [MaybeUninit<u8>; 9], ) -> usize
Format the UtcOffset into the provided buffer, returning the number of bytes written.
Trait Implementations§
Source§impl ComponentProvider for UtcOffset
impl ComponentProvider for UtcOffset
Source§const SUPPLIES_OFFSET: bool = true
const SUPPLIES_OFFSET: bool = true
Source§fn offset_is_negative(&self, _: &mut Self::State) -> bool
fn offset_is_negative(&self, _: &mut Self::State) -> bool
Source§fn offset_is_utc(&self, _state: &mut Self::State) -> bool
fn offset_is_utc(&self, _state: &mut Self::State) -> bool
Source§fn offset_hour(&self, _: &mut Self::State) -> ri8<-25, 25>
fn offset_hour(&self, _: &mut Self::State) -> ri8<-25, 25>
Source§fn offset_minute(&self, _: &mut Self::State) -> ri8<{ _ }, { _ }>
fn offset_minute(&self, _: &mut Self::State) -> ri8<{ _ }, { _ }>
Source§fn offset_second(&self, _: &mut Self::State) -> ri8<{ _ }, { _ }>
fn offset_second(&self, _: &mut Self::State) -> ri8<{ _ }, { _ }>
Source§const SUPPLIES_DATE: bool = false
const SUPPLIES_DATE: bool = false
Source§const SUPPLIES_TIME: bool = false
const SUPPLIES_TIME: bool = false
Source§const SUPPLIES_TIMESTAMP: bool = false
const SUPPLIES_TIMESTAMP: bool = false
Source§fn ordinal(&self, state: &mut Self::State) -> ru16<1, 366>
fn ordinal(&self, state: &mut Self::State) -> ru16<1, 366>
Source§fn iso_week_number(&self, state: &mut Self::State) -> ru8<1, 53>
fn iso_week_number(&self, state: &mut Self::State) -> ru8<1, 53>
Source§fn monday_based_week(&self, state: &mut Self::State) -> ru8<0, 53>
fn monday_based_week(&self, state: &mut Self::State) -> ru8<0, 53>
Source§fn sunday_based_week(&self, state: &mut Self::State) -> ru8<0, 53>
fn sunday_based_week(&self, state: &mut Self::State) -> ru8<0, 53>
Source§fn calendar_year(&self, state: &mut Self::State) -> ri32<-999_999, 999_999>
fn calendar_year(&self, state: &mut Self::State) -> ri32<-999_999, 999_999>
Source§fn iso_year(&self, state: &mut Self::State) -> ri32<-999_999, 999_999>
fn iso_year(&self, state: &mut Self::State) -> ri32<-999_999, 999_999>
Source§fn second(&self, state: &mut Self::State) -> ru8<0, { _ }>
fn second(&self, state: &mut Self::State) -> ru8<0, { _ }>
Source§fn nanosecond(&self, state: &mut Self::State) -> ru32<0, { _ }>
fn nanosecond(&self, state: &mut Self::State) -> ru32<0, { _ }>
Source§fn unix_timestamp_seconds(&self, state: &mut Self::State) -> i64
fn unix_timestamp_seconds(&self, state: &mut Self::State) -> i64
Source§fn unix_timestamp_milliseconds(&self, state: &mut Self::State) -> i64
fn unix_timestamp_milliseconds(&self, state: &mut Self::State) -> i64
Source§fn unix_timestamp_microseconds(&self, state: &mut Self::State) -> i128
fn unix_timestamp_microseconds(&self, state: &mut Self::State) -> i128
Source§fn unix_timestamp_nanoseconds(&self, state: &mut Self::State) -> i128
fn unix_timestamp_nanoseconds(&self, state: &mut Self::State) -> i128
Source§impl<'a> Deserialize<'a> for UtcOffset
impl<'a> Deserialize<'a> for UtcOffset
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'a>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'a>,
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>
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Display::fmt. Read more