pub struct Date {
pub year: i32,
pub month: u32,
pub day: u32,
}Expand description
A day of the proleptic Gregorian calendar. Months and days count from 1.
Fields§
§year: i32§month: u32§day: u32Implementations§
Source§impl Date
impl Date
pub const fn new(year: i32, month: u32, day: u32) -> Date
Sourcepub const fn is_leap_year(year: i32) -> bool
pub const fn is_leap_year(year: i32) -> bool
Whether year has a 29th of February.
Sourcepub const fn days_in_month(year: i32, month: u32) -> u32
pub const fn days_in_month(year: i32, month: u32) -> u32
The days in month of year.
Sourcepub fn today_utc() -> Date
pub fn today_utc() -> Date
Today in UTC. There is no time zone here: pass the local day to a picker when the difference matters.
Sourcepub fn today_local() -> Date
pub fn today_local() -> Date
Today in the local zone, summer time included.
Sourcepub fn add_months(self, months: i32) -> Date
pub fn add_months(self, months: i32) -> Date
The same day months later (earlier if negative), or the last day
of that month if it is shorter.
Sourcepub fn first_of_month(self) -> Date
pub fn first_of_month(self) -> Date
The first day of its month.
Sourcepub fn last_of_month(self) -> Date
pub fn last_of_month(self) -> Date
The last day of its month.
Sourcepub fn month_name(self) -> &'static str
pub fn month_name(self) -> &'static str
The month’s name, in English.
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 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
Mutably borrows from an owned value. Read more
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§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
Compare self to
key and return true if they are equal.Source§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>
Fallible version of
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a
CompactString. Read more