Skip to main content

IsmDate

Enum IsmDate 

Source
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:

VariantXSD typeSpan
Yearxsd:gYearentire calendar year
YearMonthxsd:gYearMonthentire calendar month
Datexsd:datesingle calendar day
DateHourMindateHourMinTypesingle minute (HH:MM, no seconds)
DateTimexsd:dateTimeprecise instant

§Parsing

IsmDate implements FromStr. Accepted forms:

InputVariant
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:MMDateHourMin
`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

§year: i32
§month: u8
§day: u8
§hour: u8
§minute: u8
§offset: Option<UtcOffset>

None for floating (offset-naive) time.

§

DateTime

xsd:dateTime — full ISO 8601 with seconds, optional fractional seconds, and optional UTC offset.

Fields

§year: i32
§month: u8
§day: u8
§hour: u8
§minute: u8
§second: u8
§nanosecond: u32

Fractional seconds as nanoseconds (0..=999_999_999).

§offset: Option<UtcOffset>

None for floating (offset-naive) time.

Implementations§

Source§

impl IsmDate

Source

pub fn year(&self) -> i32

The year component, always present.

Source

pub fn month(&self) -> Option<u8>

Month component, if present (1–12).

Source

pub fn day(&self) -> Option<u8>

Day component, if present (1–31).

Source

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.

Source

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)
  • DateHourMin end = (y, m, d, H, M, 59, 999_999_999)
  • DateTime end = 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.

Source

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 month
  • Date(y, m, d)"{y:04}{m:02}{d:02}"
  • DateHourMin / DateTime → the date component only

Trait Implementations§

Source§

impl Clone for IsmDate

Source§

fn clone(&self) -> IsmDate

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for IsmDate

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for IsmDate

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FromStr for IsmDate

Source§

type Err = ParseIsmDateError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for IsmDate

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for IsmDate

Source§

fn eq(&self, other: &IsmDate) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for IsmDate

Source§

impl StructuralPartialEq for IsmDate

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.