pub struct TimeOfDay {
pub hour: u8,
pub minute: u8,
pub second: u8,
}Expand description
A time of day on a 24-hour clock, with no date and no time zone.
Fields§
§hour: u8Hour, 0 to 23.
minute: u8Minute, 0 to 59.
second: u8Second, 0 to 59.
Implementations§
Source§impl TimeOfDay
impl TimeOfDay
Sourcepub fn new(hour: u8, minute: u8, second: u8) -> Self
pub fn new(hour: u8, minute: u8, second: u8) -> Self
The time hour:minute:second; each part is capped at its largest value.
Sourcepub fn parse(text: &str) -> Option<Self>
pub fn parse(text: &str) -> Option<Self>
Reads h:mm or h:mm:ss with every part in range; surrounding spaces are ignored and a
missing second is zero. Out-of-range parts such as 24:00 are None, not capped.
Sourcepub fn seconds_since_midnight(self) -> u32
pub fn seconds_since_midnight(self) -> u32
Seconds from midnight, 0 to 86 399.
Sourcepub fn from_seconds_since_midnight(seconds: u32) -> Self
pub fn from_seconds_since_midnight(seconds: u32) -> Self
The time seconds after midnight; a value past the end of a day wraps into the next one.
Trait Implementations§
impl Copy for TimeOfDay
impl Eq for TimeOfDay
Source§impl Ord for TimeOfDay
impl Ord for TimeOfDay
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for TimeOfDay
impl PartialOrd for TimeOfDay
impl StructuralPartialEq for TimeOfDay
Auto Trait Implementations§
impl Freeze for TimeOfDay
impl RefUnwindSafe for TimeOfDay
impl Send for TimeOfDay
impl Sync for TimeOfDay
impl Unpin for TimeOfDay
impl UnsafeUnpin for TimeOfDay
impl UnwindSafe for TimeOfDay
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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 moreSource§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
Fallible version of
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a
CompactString. Read more