pub struct Date {
pub year: u16,
pub month: u8,
pub day: u8,
}Expand description
A calendar date with year, month, and day components.
Represents the date portion of a TOML datetime value. Field ranges are validated during parsing:
year: 0–9999month: 1–12day: 1–31 (upper bound depends on month and leap year rules)
§Examples
use toml_spanner::{Arena, DateTime};
let dt: DateTime = "2026-03-15".parse().unwrap();
let date = dt.date().unwrap();
assert_eq!(date.year, 2026);
assert_eq!(date.month, 3);
assert_eq!(date.day, 15);Fields§
§year: u16Calendar year (0–9999).
month: u8Month of the year (1–12).
day: u8Day of the month (1–31).
Implementations§
Source§impl Date
impl Date
Sourcepub fn new(year: u16, month: u8, day: u8) -> Option<Date>
pub fn new(year: u16, month: u8, day: u8) -> Option<Date>
Builds a Date from its year, month, and day components.
Returns None when the values fall outside the TOML calendar range:
yearin0..=9999monthin1..=12dayin the range of the given month, accounting for leap years
§Examples
use toml_spanner::Date;
assert!(Date::new(2024, 2, 29).is_some());
assert!(Date::new(2023, 2, 29).is_none());
assert!(Date::new(10000, 1, 1).is_none());Trait Implementations§
impl Copy for Date
impl Eq 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