pub struct Hour(/* private fields */);
Expand description
NewType wrapper for f32
representing in-game hours(0-based).
Internally stored as a floating-point value:
0.0
→00:00
(midnight)15.5
→15:30
23.99
→ nearly23:59
§Example
use commonlibsse_ng::re::Calendar::Hour;
let hour = Hour::new(10.5); // 10:30 AM
assert_eq!(hour.to_hour(), 10);
assert_eq!(hour.to_minutes(), 30);
let max_hour = Hour::new(23.99); // Max valid hour
assert_eq!(max_hour.to_hour(), 23);
assert_eq!(max_hour.to_minutes(), 59);
Implementations§
Source§impl Hour
impl Hour
Sourcepub const fn new(value: f32) -> Self
pub const fn new(value: f32) -> Self
Creates a new Hour
instance.
§Example
use commonlibsse_ng::re::Calendar::Hour;
let hour = Hour::new(9.75); // 9:45 AM
assert_eq!(hour.to_hour(), 9);
assert_eq!(hour.to_minutes(), 45);
Sourcepub const fn to_hour(self) -> u32
pub const fn to_hour(self) -> u32
Returns the hour component (0..=23
).
§Example
use commonlibsse_ng::re::Calendar::Hour;
let hour = Hour::new(14.25); // 14:15
assert_eq!(hour.to_hour(), 14);
Sourcepub fn to_minutes(self) -> u32
pub fn to_minutes(self) -> u32
Returns the minute component (0..=59
).
§Example
use commonlibsse_ng::re::Calendar::Hour;
let hour = Hour::new(12.5); // 12:30 PM
assert_eq!(hour.to_minutes(), 30);
let almost_full = Hour::new(23.99); // Nearly 23:59
assert_eq!(almost_full.to_minutes(), 59);
Trait Implementations§
impl Copy for Hour
impl StructuralPartialEq for Hour
Auto Trait Implementations§
impl Freeze for Hour
impl RefUnwindSafe for Hour
impl Send for Hour
impl Sync for Hour
impl Unpin for Hour
impl UnwindSafe for Hour
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