pub struct Date { /* private fields */ }
Expand description
Indicates the date.
Used for the nightly versions of rust.
The timezone is not explicitly specified here, and matches whatever one the rust team uses for nightly releases.
Implementations§
Source§impl Date
impl Date
Sourcepub fn new(year: u32, month: u32, day: u32) -> Self
pub fn new(year: u32, month: u32, day: u32) -> Self
Create a date, using YYYY-MM-DD format (ISO 8601).
§Panics
May panic if the date is invalid.
See Self::try_new
for a version that returns an error instead.
§Examples
let x = Date::new(2018, 10, 21);
let y = Date::new(2017, 11, 30);
assert!(x.is_since(y));
assert!(x.is_since(x));
Sourcepub fn is_since(&self, start: Date) -> bool
pub fn is_since(&self, start: Date) -> bool
Check if this date is later than or equal to the specified start.
Equivalent to self >= start
, but potentially clearer.
§Example
assert!(Date::new(2024, 11, 16).is_since(Date::new(2024, 7, 28)));
Sourcepub fn is_before(&self, end: Date) -> bool
pub fn is_before(&self, end: Date) -> bool
Check if this date is before the specified end.
Equivalent to self < end
, but potentially clearer.
§Example
assert!(Date::new(2018, 12, 14).is_before(Date::new(2022, 8, 16)));
assert!(Date::new(2024, 11, 14).is_before(Date::new(2024, 12, 7)));
assert!(Date::new(2024, 11, 14).is_before(Date::new(2024, 11, 17)));
Trait Implementations§
Source§impl Ord for Date
impl Ord for Date
Source§impl PartialOrd for Date
impl PartialOrd for Date
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