pub struct Date {
pub year: i64,
pub month: i64,
pub day: i64,
}Expand description
A Gregorian civil date. Validation is independent of time zones and clocks.
Fields§
§year: i64§month: i64§day: i64Implementations§
Source§impl Date
impl Date
pub const MIN: Self
pub const MAX: Self
pub fn new(year: i64, month: i64, day: i64) -> Option<Self>
pub fn valid(self) -> bool
pub fn first_of_month(self) -> Self
pub fn last_of_month(self) -> Self
pub fn add_days(self, days: i64) -> Option<Self>
Sourcepub fn add_months(self, months: i64) -> Option<Self>
pub fn add_months(self, months: i64) -> Option<Self>
Return the first day of the month at the given offset.
Sourcepub fn add_months_clamped(self, months: i64) -> Option<Self>
pub fn add_months_clamped(self, months: i64) -> Option<Self>
Shift by whole months, retaining the day or clamping it to the target month’s end.
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 Forget for Date
impl Freeze for Date
impl Move 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