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 fn parse_str(input: &str) -> Option<ParsedDate>
pub fn parse_str(input: &str) -> Option<ParsedDate>
Tries to parse a SAC13 date.
For details about the supported formats see SacOrGreg::parse_str.
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.