pub enum IsmDate {
Year(i32),
YearMonth(i32, u8),
Date(i32, u8, u8),
DateHourMin {
year: i32,
month: u8,
day: u8,
hour: u8,
minute: u8,
offset: Option<UtcOffset>,
},
DateTime {
year: i32,
month: u8,
day: u8,
hour: u8,
minute: u8,
second: u8,
nanosecond: u32,
offset: Option<UtcOffset>,
},
}Expand description
ISM date precision-tier union, mirroring ISO8601DateTimeType.
Each variant represents the span for its precision tier:
| Variant | XSD type | Span |
|---|---|---|
Year | xsd:gYear | entire calendar year |
YearMonth | xsd:gYearMonth | entire calendar month |
Date | xsd:date | single calendar day |
DateHourMin | dateHourMinType | single minute (HH:MM, no seconds) |
DateTime | xsd:dateTime | precise instant |
§Parsing
IsmDate implements FromStr. Accepted forms:
| Input | Variant |
|---|---|
YYYY (e.g. 2003) | Year |
YYYY-MM (e.g. 2003-04) | YearMonth |
YYYY-MM-DD (e.g. 2003-04-15) | Date |
YYYYMMDD (CAPCO no-hyphen form, e.g. 20030415) | Date |
YYYY-MM-DDTHH:MM, optionally Z or ±HH:MM | DateHourMin |
| `YYYY-MM-DDTHH:MM:SS[.frac][Z | ±HH:MM]` |
§Display
fmt::Display produces canonical ISO 8601 form (with hyphens and T
separator) suitable for round-trip: IsmDate::from_str(&date.to_string()) == Ok(date).
Variants§
Year(i32)
xsd:gYear — e.g. "2003". Represents the span Jan 1 – Dec 31 of
the given year (inclusive).
YearMonth(i32, u8)
xsd:gYearMonth — e.g. "2003-04". Represents the entire month in
the given year.
Date(i32, u8, u8)
xsd:date — e.g. "2003-04-15". A single calendar day.
Also accepts the CAPCO no-hyphen form "YYYYMMDD" on input;
Display always produces "YYYY-MM-DD".
DateHourMin
dateHourMinType — e.g. "2003-04-15T14:30Z".
Date + hour + minute with optional UTC offset. The XSD regex restricts
to HH:MM only (no seconds or fractional seconds); sub-minute precision
is represented by DateTime instead.
Fields
DateTime
xsd:dateTime — full ISO 8601 with seconds, optional fractional
seconds, and optional UTC offset.
Implementations§
Source§impl IsmDate
impl IsmDate
Sourcepub fn contains(&self, point: &IsmDate) -> bool
pub fn contains(&self, point: &IsmDate) -> bool
Returns true if point falls within the temporal span this date
represents.
Semantics: a coarser IsmDate (e.g. Year(2003)) represents a span
(all of 2003). A finer one (e.g. Date(2003, 6, 15)) represents a
narrower span. self.contains(point) is true iff the span of
point is entirely within the span of self.
Year(2003) contains:
Year(2003)✓ (same span)YearMonth(2003, 4)✓ (April 2003 ⊂ 2003)Date(2003, 12, 31)✓Date(2004, 1, 1)✗
YearMonth(2003, 4) contains:
Year(2003)✗ (coarser than self)Date(2003, 4, 1)✓Date(2003, 5, 1)✗
§Timezone handling
Offsets are compared in their represented form, not after UTC
normalization. DateHourMin { hour: 14, offset: UTC } and
DateHourMin { hour: 9, offset: -05:00 } are the same civil instant
but contains does not normalize across offsets.
Sourcepub fn end_cmp(&self, other: &IsmDate) -> Ordering
pub fn end_cmp(&self, other: &IsmDate) -> Ordering
Compare two IsmDate values by their end-of-span instants.
This is the correct comparator for the MaxDate lattice operation:
“which declassification date is the latest (most conservative)?”
Year(2003).end_cmp(Date(2003, 6, 15)) returns Greater because the
year 2003 extends through December 31, whereas June 15 ends earlier.
Coarser spans fill in the maximum value for unspecified components:
Year(y)end = (y, 12, 31, 23, 59, 59, 999_999_999)YearMonth(y, m)end = (y, m, last-day-of-month, 23, 59, 59, 999_999_999)Date(y, m, d)end = (y, m, d, 23, 59, 59, 999_999_999)DateHourMinend = (y, m, d, H, M, 59, 999_999_999)DateTimeend = the precise instant
When civil end-of-span components are equal, the value with the more
negative UTC offset (i.e. further behind UTC, representing a later UTC
instant) is considered Greater. For example, 2003-04-15T10:30-05:00
(= 15:30 UTC) compares Greater than 2003-04-15T10:30Z (= 10:30 UTC).
Floating (offset-naive) values treat offset as zero for tie-breaking.
Sourcepub fn to_maxdate_str(&self) -> Box<str>
pub fn to_maxdate_str(&self) -> Box<str>
Returns the end-of-span as a sortable YYYYMMDD string for use as a
MaxDate lattice key.
The string is always 8 ASCII digits. Lex order on these strings is
chronological, so MaxDate’s lex join produces the correct
span-aware “latest” date.
Year(y)→"{y:04}1231"(December 31 of year)YearMonth(y, m)→ last day of monthDate(y, m, d)→"{y:04}{m:02}{d:02}"DateHourMin / DateTime→ the date component only