pub struct Year(/* private fields */);
Expand description
Represents the 0-based year.
- Positive years represent years in the Common Era (CE).
- Negative years represent years Before Common Era (BCE).
§Examples
use commonlibsse_ng::re::Calendar::Year;
let year = Year::new(77.0);
assert_eq!(year.to_year(), 77); // CE
let year_bce = Year::new(-500.0);
assert_eq!(year_bce.to_year(), -500); // BCE
Implementations§
Source§impl Year
impl Year
Sourcepub const DEFAULT: Self
pub const DEFAULT: Self
The default value for Year
(0.0
), representing the start of the Common Era (1 CE).
Sourcepub const GAME_DEFAULT: Self
pub const GAME_DEFAULT: Self
The game-defined default year (77.0
).
Sourcepub const fn new(value: f32) -> Self
pub const fn new(value: f32) -> Self
Creates a new Year
with the specified value.
- Positive values indicate CE years.
- Negative values indicate BCE years.
§Examples
use commonlibsse_ng::re::Calendar::Year;
let year = Year::new(105.5);
assert_eq!(year.to_year(), 105); // CE
let year_bce = Year::new(-200.0);
assert_eq!(year_bce.to_year(), -200); // BCE
Sourcepub const fn to_year(self) -> i32
pub const fn to_year(self) -> i32
Returns the year as an integer (i32
), truncating the decimal part.
- Positive values represent CE (e.g.,
2025
→2025 CE
). - Negative values represent BCE (e.g.,
-500
→500 BCE
).
§Examples
use commonlibsse_ng::re::Calendar::Year;
let year = Year::new(203.75);
assert_eq!(year.to_year(), 203); // CE
let year_bce = Year::new(-44.9);
assert_eq!(year_bce.to_year(), -44); // BCE
Trait Implementations§
impl Copy for Year
impl StructuralPartialEq for Year
Auto Trait Implementations§
impl Freeze for Year
impl RefUnwindSafe for Year
impl Send for Year
impl Sync for Year
impl Unpin for Year
impl UnwindSafe for Year
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