pub struct Date { /* private fields */ }Expand description
A calendar date in the proleptic Gregorian calendar, from 0001-01-01 to 9999-12-31. It has no timezone, time of day, or duration, and its components never pass through an instant.
With serde, it reads only from a native SOML date, not from a string, and it is written as a native date. Other formats, including JSON, see its exact YYYY-MM-DD text.
let date = soml::Date::new(1582, 10, 10).unwrap();
assert_eq!(date.to_string(), "1582-10-10");
assert_eq!((date.year(), date.month(), date.day()), (1582, 10, 10));Implementations§
Trait Implementations§
impl Copy for Date
Source§impl<'de> Deserialize<'de> for Date
impl<'de> Deserialize<'de> for Date
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Date
Source§impl FromStr for Date
Reads an exact YYYY-MM-DD date, rejecting impossible components.
impl FromStr for Date
Reads an exact YYYY-MM-DD date, rejecting impossible components.
let date: soml::Date = "1582-10-10".parse()?;
assert_eq!(date.to_string(), "1582-10-10");
assert!("2026-02-30".parse::<soml::Date>().is_err());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