pub struct DocDate {
pub year: u32,
pub month: u32,
pub day: u32,
}Expand description
A calendar date as an ADR writes one: YYYY-MM-DD, in a frontmatter
last-modified: field or a version-history row’s Date cell.
Three u32s rather than a chrono type because the only thing asked of it
is ordering, and ISO-8601 components compare correctly component-wise — the
same reason DocVersion is a pair of numbers. Adding a date library to
compare two strings the parser has already split would be the larger change.
Nothing here validates that a date exists: 2026-02-31 parses. A check that
refused impossible dates would be a different rule with a different failure
mode, and the rules that consume this only ever ask which of two dates is
later.
Fields§
§year: u32Four-digit year.
month: u32Month, 1..=12 as written — unvalidated.
day: u32Day, as written — unvalidated.
Implementations§
Source§impl DocDate
impl DocDate
Sourcepub fn parse(s: &str) -> Option<Self>
pub fn parse(s: &str) -> Option<Self>
Parse a string that is exactly YYYY-MM-DD — four digits, two, two.
Anything else is None, which is how a TBD, an empty cell or a prose
date is skipped rather than guessed at.
Fixed width is the contract, not an accident. A looser split would
accept 2026-8-1, and Display would then render
it back as 2026-08-01 — so a violation message would quote a date the
document does not contain. A gate that reports what a file says has to
say what the file says.
The cost of the strictness is that a hand-typed 2026-8-1 reads as no
date claim rather than as a date, exactly as TBD does. That is the
same trade every other cell in this column already makes, and it is the
safe direction: the rules that consume a date only ever report a
contradiction, so a skipped cell loses a finding while a guessed one
invents one. Every date across this repository’s twenty ADRs is
zero-padded, and roteiro spec generates the frontmatter field, so
nothing today is affected either way.
Trait Implementations§
impl Copy for DocDate
impl Eq for DocDate
Source§impl Ord for DocDate
impl Ord for DocDate
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for DocDate
impl PartialOrd for DocDate
impl StructuralPartialEq for DocDate
Auto Trait Implementations§
impl Freeze for DocDate
impl RefUnwindSafe for DocDate
impl Send for DocDate
impl Sync for DocDate
impl Unpin for DocDate
impl UnsafeUnpin for DocDate
impl UnwindSafe for DocDate
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
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.