pub struct CalendarDate {
pub year: i32,
pub month: u8,
pub day: u8,
}Expand description
A calendar date, comparable by (year, month, day).
The derived Ord compares fields in declaration order, which for these
three fields is chronological order.
Fields§
§year: i32§month: u8§day: u8Implementations§
Source§impl CalendarDate
impl CalendarDate
Sourcepub const fn new(year: i32, month: u8, day: u8) -> Self
pub const fn new(year: i32, month: u8, day: u8) -> Self
Construct a date from year, month and day.
Sourcepub const fn is_plausible(&self) -> bool
pub const fn is_plausible(&self) -> bool
Whether the month is 1–12 and the day 1–31.
A coarse well-formedness check, not a calendar validation: it accepts 31 February. Use it to reject transposed or garbage input at an ingestion boundary, not to prove a date exists.
Sourcepub fn parse_iso(s: &str) -> Option<Self>
pub fn parse_iso(s: &str) -> Option<Self>
Parse a strict YYYY-MM-DD date.
Returns None for anything else — wrong length, wrong separators,
non-digits, or components failing Self::is_plausible. Deliberately
strict and deliberately not lenient about partial dates: a compliance
determination keyed on a date must never run against one the declarer
did not actually state.
Trait Implementations§
Source§impl Clone for CalendarDate
impl Clone for CalendarDate
Source§fn clone(&self) -> CalendarDate
fn clone(&self) -> CalendarDate
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for CalendarDate
Source§impl Debug for CalendarDate
impl Debug for CalendarDate
impl Eq for CalendarDate
Source§impl Ord for CalendarDate
impl Ord for CalendarDate
Source§fn cmp(&self, other: &CalendarDate) -> Ordering
fn cmp(&self, other: &CalendarDate) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for CalendarDate
impl PartialEq for CalendarDate
Source§impl PartialOrd for CalendarDate
impl PartialOrd for CalendarDate
impl StructuralPartialEq for CalendarDate
Auto Trait Implementations§
impl Freeze for CalendarDate
impl RefUnwindSafe for CalendarDate
impl Send for CalendarDate
impl Sync for CalendarDate
impl Unpin for CalendarDate
impl UnsafeUnpin for CalendarDate
impl UnwindSafe for CalendarDate
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