pub struct TimeValue {
pub hour: u8,
pub minute: u8,
}Expand description
A wall-clock time with minute precision.
§Examples
use ailloli_ui_core::TimeValue;
let time = TimeValue::new(9, 30);
assert_eq!((time.hour, time.minute), (9, 30));Fields§
§hour: u8Hour in 0..=23 for values created by TimeValue::new.
minute: u8Minute in 0..=59 for values created by TimeValue::new.
Implementations§
Source§impl TimeValue
impl TimeValue
Sourcepub fn new(hour: u8, minute: u8) -> Self
pub fn new(hour: u8, minute: u8) -> Self
Creates a time, clamping the hour to 23 and the minute to 59.
§Examples
use ailloli_ui_core::TimeValue;
assert_eq!(TimeValue::new(25, 90), TimeValue { hour: 23, minute: 59 });Sourcepub fn total_minutes(self) -> u16
pub fn total_minutes(self) -> u16
Returns minutes elapsed since midnight in 0..=1439.
§Examples
use ailloli_ui_core::TimeValue;
assert_eq!(TimeValue::new(1, 30).total_minutes(), 90);Sourcepub fn from_total_minutes(minutes: u16) -> Self
pub fn from_total_minutes(minutes: u16) -> Self
Creates a time from minutes since midnight, clamped to 23:59.
§Examples
use ailloli_ui_core::TimeValue;
assert_eq!(TimeValue::from_total_minutes(75), TimeValue::new(1, 15));Sourcepub fn format(self, format: TimeFormat) -> String
pub fn format(self, format: TimeFormat) -> String
Formats this value using the selected 12- or 24-hour representation.
§Examples
use ailloli_ui_core::{TimeFormat, TimeValue};
assert_eq!(TimeValue::new(0, 5).format(TimeFormat::Hour24), "00:05");Trait Implementations§
Source§impl Ord for TimeValue
impl Ord for TimeValue
Source§impl PartialOrd for TimeValue
impl PartialOrd for TimeValue
impl Copy for TimeValue
impl Eq for TimeValue
impl StructuralPartialEq for TimeValue
Auto Trait Implementations§
impl Freeze for TimeValue
impl RefUnwindSafe for TimeValue
impl Send for TimeValue
impl Sync for TimeValue
impl Unpin for TimeValue
impl UnwindSafe for TimeValue
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