pub struct Date { /* private fields */ }Expand description
A calendar date (year, month, day), always valid.
use ravenrs_widgets::Date;
let d = Date::new(2026, 1, 31).unwrap();
assert_eq!(d.add_months(1).to_string(), "2026-02-28");
assert_eq!(d.add_days(1).short(), "Feb 1, 2026");
assert!(Date::new(2026, 2, 30).is_none());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>
Returns None for impossible dates (e.g. February 30).
Sourcepub fn first_of_month(self) -> Self
pub fn first_of_month(self) -> Self
The first day of this date’s month.
Sourcepub fn add_months(self, months: i32) -> Self
pub fn add_months(self, months: i32) -> Self
Moves by whole months, clamping the day (Jan 31 + 1 month = Feb 28/29).
Sourcepub fn from_days(days: i64) -> Self
pub fn from_days(days: i64) -> Self
The date days days after 1970-01-01 (inverse of Date::to_days).
Sourcepub fn month_title(self) -> String
pub fn month_title(self) -> String
“October 2026”.
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
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,
§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
Checks if this value is equivalent to the given key. Read more