pub struct Date { /* private fields */ }Expand description
A calendar date.
Implementations§
Source§impl Date
impl Date
Sourcepub fn new(year: i32, month: u8, day: u8) -> Option<Self>
pub fn new(year: i32, month: u8, day: u8) -> Option<Self>
The date year-month-day, or None when no such day exists.
Sourcepub fn today_local() -> Self
pub fn today_local() -> Self
Today where the machine stands, from the system clock and the system time zone. Falls back
to Date::today_utc where the zone is unknown; local_offset tells you which it is.
Sourcepub fn parse(text: &str) -> Result<Self, String>
pub fn parse(text: &str) -> Result<Self, String>
Reads YYYY-MM-DD: four or more digits for the year, then two for the month and the day,
with a leading - for a year before the era. The calendar is checked, so 2026-02-30 is an
error, and surrounding spaces are ignored.
use qframe::date::Date;
assert_eq!(Date::parse("2026-09-17"), Ok(Date::new(2026, 9, 17).expect("a real day")));
assert!(Date::parse("2026-02-30").is_err());Sourcepub fn from_days(days: i64) -> Self
pub fn from_days(days: i64) -> Self
The date days after 1970-01-01. Years beyond the range of i32 are clamped to it.
Sourcepub fn add_months(self, months: i32) -> Self
pub fn add_months(self, months: i32) -> Self
The same day months later (earlier when negative), moved back to the last day of a
shorter month: January 31 plus one month is February 28 or 29.
Sourcepub fn first_of_month(self) -> Self
pub fn first_of_month(self) -> Self
The first day of this date’s month.
Sourcepub fn start_of_week(self, start: Weekday) -> Self
pub fn start_of_week(self, start: Weekday) -> Self
The date the week containing this date starts on, for weeks starting on start.
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,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(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§
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,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more