pub struct DateValue {
pub year: i32,
pub month: u8,
pub day: u8,
}Expand description
A date in the proleptic Gregorian calendar.
§Examples
use ailloli_ui_core::DateValue;
let date = DateValue::new(2024, 2, 31);
assert_eq!(date.format_yyyy_mm_dd(), "2024-02-29");Fields§
§year: i32Signed calendar year.
month: u8One-based month in 1..=12 for values created by DateValue::new.
day: u8One-based day, bounded by the selected month for validated values.
Implementations§
Source§impl DateValue
impl DateValue
Sourcepub fn new(year: i32, month: u8, day: u8) -> Self
pub fn new(year: i32, month: u8, day: u8) -> Self
Creates a date, clamping the month and day to a valid calendar value.
Months clamp to 1..=12; days then clamp to the valid range for that
month and year.
§Examples
use ailloli_ui_core::DateValue;
assert_eq!(DateValue::new(2024, 2, 31), DateValue { year: 2024, month: 2, day: 29 });Sourcepub fn month_value(self) -> MonthValue
pub fn month_value(self) -> MonthValue
Returns this date’s year and month.
§Examples
use ailloli_ui_core::{DateValue, MonthValue};
assert_eq!(DateValue::new(2024, 7, 3).month_value(), MonthValue::new(2024, 7));Sourcepub fn format_yyyy_mm_dd(self) -> String
pub fn format_yyyy_mm_dd(self) -> String
Formats the date as a zero-padded YYYY-MM-DD string.
Years wider than four digits are not truncated.
§Examples
use ailloli_ui_core::DateValue;
assert_eq!(DateValue::new(2024, 7, 3).format_yyyy_mm_dd(), "2024-07-03");Trait Implementations§
Source§impl Ord for DateValue
impl Ord for DateValue
Source§impl PartialOrd for DateValue
impl PartialOrd for DateValue
impl Copy for DateValue
impl Eq for DateValue
impl StructuralPartialEq for DateValue
Auto Trait Implementations§
impl Freeze for DateValue
impl RefUnwindSafe for DateValue
impl Send for DateValue
impl Sync for DateValue
impl Unpin for DateValue
impl UnwindSafe for DateValue
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