#[repr(transparent)]pub struct GameDay(pub f32);
Expand description
Represents a day in a 0-based game.
This usually takes the range 0.0..=30.0
range.
Tuple Fields§
§0: f32
Implementations§
Source§impl GameDay
impl GameDay
Sourcepub const fn new(value: f32) -> Self
pub const fn new(value: f32) -> Self
Creates a new GameDay
instance with the specified value.
§Example
let game_day = GameDay::new(5.0);
assert_eq!(game_day.0, 5.0);
Sourcepub const fn day_of_week(&self) -> u32
pub const fn day_of_week(&self) -> u32
Returns the day of the week (0-6), 0 based value.
§Example
let game_day = GameDay::new(3.0);
assert_eq!(game_day.day_of_week(), 3);
Sourcepub const fn to_clamp_day(self, month: u32) -> u32
pub const fn to_clamp_day(self, month: u32) -> u32
Clamps the day value based on the month’s maximum days.
When month is in the range of 1 to 12, a valid value is returned.
§Example
use commonlibsse_ng::re::Calendar::GameDay;
let game_day = GameDay::new(32.0);
assert_eq!(game_day.to_clamp_day(2), 28); // Sun's Dawn (28 days)
assert_eq!(game_day.to_clamp_day(0), 31); // Underflow (Fallback to 31 days)
assert_eq!(game_day.to_clamp_day(12), 31); // Overflow (Fallback to 31 days)
assert_eq!(game_day.to_clamp_day(300), 31); // Overflow (Fallback to 31 days)
Sourcepub const fn ordinal_suffix(&self) -> &'static str
pub const fn ordinal_suffix(&self) -> &'static str
Returns the ordinal suffix for the day (e.g., st
, nd
, rd
, th
).
§Example
use commonlibsse_ng::re::Calendar::GameDay;
let game_day = GameDay::new(21.0);
assert_eq!(game_day.ordinal_suffix(), "st");
Sourcepub const fn to_week(self) -> Option<Week>
pub const fn to_week(self) -> Option<Week>
Converts GameDay
into a Week
enum.
Returns None
if the GameDay
value is out of range (greater than 7.0).
§Example
use commonlibsse_ng::re::Calendar::{GameDay, Week};
let game_day = GameDay::new(1.0);
assert_eq!(game_day.to_week(), Some(Week::Morndas));
Trait Implementations§
impl Copy for GameDay
impl StructuralPartialEq for GameDay
Auto Trait Implementations§
impl Freeze for GameDay
impl RefUnwindSafe for GameDay
impl Send for GameDay
impl Sync for GameDay
impl Unpin for GameDay
impl UnwindSafe for GameDay
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