pub struct Date { /* private fields */ }Expand description
A calendar date (year, month, day) in the Gregorian calendar.
Implementations§
Source§impl Date
impl Date
Sourcepub fn from_ymd(year: i32, month: u8, day: u8) -> Result<Date, DateTimeError>
pub fn from_ymd(year: i32, month: u8, day: u8) -> Result<Date, DateTimeError>
Create and validate a calendar date.
§Errors
Returns DateTimeError::InvalidMonth if month is not in 1..=12.
Returns DateTimeError::InvalidDay if day is not valid for the year and month.
Sourcepub fn day_of_week(&self) -> u8
pub fn day_of_week(&self) -> u8
Day of the week (0 = Monday, 1 = Tuesday, …, 6 = Sunday).
Sourcepub const fn is_leap_year(&self) -> bool
pub const fn is_leap_year(&self) -> bool
Whether this date falls in a leap year.
Trait Implementations§
impl Copy for Date
impl Eq for Date
Source§impl Ord for Date
impl Ord for Date
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
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Date
impl PartialOrd 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 UnsafeUnpin 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