pub struct Date { /* private fields */ }Expand description
A calendar date, written and read as YYYY-MM-DD.
Implementations§
Source§impl Date
impl Date
pub fn year(self) -> i32
pub fn month(self) -> u32
pub fn day(self) -> u32
Sourcepub fn checked_plus_days(self, days: i64) -> Option<Self>
pub fn checked_plus_days(self, days: i64) -> Option<Self>
The date days after this one (before it if negative), or None
outside years 0 to 9999.
Sourcepub fn date_at(self, time: f64) -> Option<Self>
pub fn date_at(self, time: f64) -> Option<Self>
The date that time falls on, with this date as day 0, or None
outside years 0 to 9999.
Sourcepub fn days_until(self, other: Date) -> i64
pub fn days_until(self, other: Date) -> i64
Days from this date to other, negative if other is earlier.
Sourcepub fn start_of(self, s: &str) -> f64
pub fn start_of(self, s: &str) -> f64
The start of the date in s, in days from this date, for dates
written in code: start.start_of("2026-06-01").
§Panics
When s is not a valid YYYY-MM-DD date.
Sourcepub fn end_of(self, s: &str) -> f64
pub fn end_of(self, s: &str) -> f64
The end of the date in s, Date::start_of plus one, for an
inclusive bound such as the end of a run.
§Panics
When s is not a valid YYYY-MM-DD date.
pub fn weekday(self) -> Weekday
Sourcepub fn week(self, system: WeekSystem) -> Option<Week>
pub fn week(self, system: WeekSystem) -> Option<Week>
The week this date falls in; near New Year it may belong to the
year before or after. None for the first days of year 0, whose
week belongs to year -1.
Sourcepub fn start_of_week(self, s: &str, system: WeekSystem) -> f64
pub fn start_of_week(self, s: &str, system: WeekSystem) -> f64
The start of the week in s, in days from this date, for weeks
written in code: start.start_of_week("2026-W12", WeekSystem::Epi).
§Panics
When s is not a valid YYYY-Www week in system.
Sourcepub fn end_of_week(self, s: &str, system: WeekSystem) -> f64
pub fn end_of_week(self, s: &str, system: WeekSystem) -> f64
The end of the week in s, Date::start_of_week plus seven.
§Panics
When s is not a valid YYYY-Www week in system.
Trait Implementations§
impl Copy for Date
Source§impl<'de> Deserialize<'de> for Date
impl<'de> Deserialize<'de> for Date
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
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,
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§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.