pub struct Date { /* private fields */ }Expand description
Proleptic Gregorian calendar date.
Implementations§
Source§impl Date
impl Date
Sourcepub const MAX: Date
pub const MAX: Date
December 31st, tens of thousands of years from the day you’re reading this.
pub fn day_of_week(self) -> Day
Sourcepub fn plus_one_day(self) -> Date
pub fn plus_one_day(self) -> Date
Returns the date one day later than self.
§Panics
Will panic in debug mode only if the resulting date would exceed
Date::MAX.
Sourcepub fn plus_one_week(self) -> Date
pub fn plus_one_week(self) -> Date
Returns the date one week later than self.
§Panics
Will panic in debug mode only if the resulting date would exceed
Date::MAX.
Sourcepub fn from_ymd(year: u16, month: u8, day: u8) -> Result<Date>
pub fn from_ymd(year: u16, month: u8, day: u8) -> Result<Date>
Constructs a date in the specified year, month, and day. All three fields are 1-based.
§Errors
Returns Err if the date is invalid. For example, you can’t
construct a nonsensical date like February 40th.
§Examples
use leap::Date;
assert_eq!(
Date::from_ymd(2000, 1, 1)
.expect("January 1st, 2000")
.to_string(),
"2000-01-01"
);pub fn day(self) -> u8
pub fn month(self) -> u8
pub fn year(self) -> u16
Sourcepub fn is_leap_day(self) -> bool
pub fn is_leap_day(self) -> bool
Returns true iff this date is February 29.
Trait Implementations§
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