Struct UtcOffset
#[repr(C)]
pub struct UtcOffset { /* private fields */ }
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.
Implementations
impl UtcOffset
const UTC: Self = _;A
UtcOffsetthat is UTC.# use UtcOffset; # use offset; assert_eq!;const fn from_hms(hours: i8, minutes: i8, seconds: i8) -> Result<Self, ComponentRange>Create a
UtcOffsetrepresenting 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.
# use UtcOffset; assert_eq!; assert_eq!; # Ok::const fn from_whole_seconds(seconds: i32) -> Result<Self, ComponentRange>Create a
UtcOffsetrepresenting an offset by the number of seconds provided.# use UtcOffset; assert_eq!; # Ok::const fn as_hms(self) -> (i8, i8, i8)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.
# use offset; assert_eq!; assert_eq!;const fn whole_hours(self) -> i8Obtain the number of whole hours the offset is from UTC. A positive value indicates an offset to the east; a negative to the west.
# use offset; assert_eq!; assert_eq!;const fn whole_minutes(self) -> i16Obtain the number of whole minutes the offset is from UTC. A positive value indicates an offset to the east; a negative to the west.
# use offset; assert_eq!; assert_eq!;const fn minutes_past_hour(self) -> i8Obtain the number of minutes past the hour the offset is from UTC. A positive value indicates an offset to the east; a negative to the west.
# use offset; assert_eq!; assert_eq!;const fn whole_seconds(self) -> i32Obtain the number of whole seconds the offset is from UTC. A positive value indicates an offset to the east; a negative to the west.
# use offset; assert_eq!; assert_eq!;const fn seconds_past_minute(self) -> i8Obtain the number of seconds past the minute the offset is from UTC. A positive value indicates an offset to the east; a negative to the west.
# use offset; assert_eq!; assert_eq!;const fn is_utc(self) -> boolCheck if the offset is exactly UTC.
# use offset; assert!; assert!; assert!;const fn is_positive(self) -> boolCheck if the offset is positive, or east of UTC.
# use offset; assert!; assert!; assert!;const fn is_negative(self) -> boolCheck if the offset is negative, or west of UTC.
# use offset; assert!; assert!; assert!;
Trait Implementations
impl Clone for UtcOffset
fn clone(&self) -> UtcOffset
impl Copy for UtcOffset
impl Debug for UtcOffset
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Display for UtcOffset
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Eq for UtcOffset
impl Hash for UtcOffset
fn hash<H>(&self, state: &mut H) where H: Hasher,
impl Neg for UtcOffset
type Output = UtcOffset;fn neg(self) -> Self::Output
impl Ord for UtcOffset
fn cmp(&self, other: &Self) -> Ordering
impl PartialEq for UtcOffset
fn eq(&self, other: &Self) -> bool
impl PartialOrd for UtcOffset
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
impl SmartDisplay for UtcOffset
type Metadata = ();fn metadata(&self, FormatterOptions) -> Metadata<'_, Self>fn fmt(&self, f: &mut Formatter<'_>) -> Result
Auto Trait Implementations
impl Freeze for UtcOffset
impl RefUnwindSafe for UtcOffset
impl Send for UtcOffset
impl Sync for UtcOffset
impl Unpin for UtcOffset
impl UnsafeUnpin for UtcOffset
impl UnwindSafe for UtcOffset
Blanket Implementations
impl<T> Any for UtcOffset
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for UtcOffset
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for UtcOffset
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for UtcOffset
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for UtcOffset
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for UtcOffset
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T> ToString for UtcOffset
where
T: Display + ?Sized,
fn to_string(&self) -> String
impl<T, U> Into<U> for UtcOffset
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for UtcOffset
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for UtcOffset
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>