pub struct Date { /* private fields */ }Expand description
SAC13 date.
Consists of the three components year, month and day.
Check the module root documentation for details about the SAC13 calendar and its dates. You can also check out the documentation for Year and Month.
§Examples
use sac13::prelude::*;
// Hard-coded values can be constructed with a compile-time checked macro.
let date = date!(M024 - 03 - 12);Implementations§
Source§impl Date
impl Date
Sourcepub const fn from_ymd(year: Year, month: Month, day: u8) -> Option<Self>
pub const fn from_ymd(year: Year, month: Month, day: u8) -> Option<Self>
SAC13 date from given year, month, day.
Returns None for invalid dates.
Examples
use sac13::prelude::*;
let y = Year::new(12020).unwrap();
let m = Month::new(5).unwrap();
let date = Date::from_ymd(y,m,16).unwrap();Sourcepub const fn from_ymd_untyped(year: u16, month: u8, day: u8) -> Option<Self>
pub const fn from_ymd_untyped(year: u16, month: u8, day: u8) -> Option<Self>
Like from_ymd() but from integers instead of typed Year and Month.
Returns None for invalid dates.
§Examples
use sac13::{Date,date};
assert_eq!(Date::from_ymd_untyped(12020,02,16), Some(date!(M020 - 02 - 16)));
assert_eq!(Date::from_ymd_untyped(12020,02,29), None); // April 29th does not exist in SAC13Sourcepub const fn weekday_ordinal(&self) -> u8
pub const fn weekday_ordinal(&self) -> u8
SAC13 Weekday ordinal.
Returns which day of the week it is. Typically 1-7, 8 on synchronization days. Note that 1-7 are NOT synonymous with Monday - Sunday. SAC13 doesn’t have weekdays in the typical sense.
Sourcepub const fn month_len(year: Year, month: Month) -> u8
pub const fn month_len(year: Year, month: Month) -> u8
All months have 28 days, except (Addenduary)Month::Addenduary, and (August)Month::August on leap years, which are 29 days long.
Trait Implementations§
Source§impl CalendarDate for Date
impl CalendarDate for Date
Source§impl Ord for Date
impl Ord for Date
Source§impl PartialOrd for Date
impl PartialOrd for Date
impl Copy for Date
impl Eq for Date
impl StructuralPartialEq for Date
Auto Trait Implementations§
impl Freeze for Date
impl RefUnwindSafe for Date
impl Send for Date
impl Sync for Date
impl Unpin for Date
impl UnwindSafe for Date
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