Skip to main content

DateValue

Struct DateValue 

Source
pub struct DateValue {
    pub value: String,
    pub note: Option<String>,
}
Expand description

An EDTF date value, with an optional opaque note.

value is the canonical EDTF string driving all date computation (sorting, disambiguation, fallback selection). note is optional, uninterpreted display text a data producer supplies alongside the date — e.g. source-calendar wording such as 民国三十六年 next to a Gregorian value of "1947". Citum never parses, converts, or validates note; see docs/specs/CALENDAR_DATE_ANNOTATIONS.md.

The wire format is backward compatible: a bare EDTF string ("1947") deserializes with note: None and serializes back to the same bare string. Supplying a note requires the mapping form { value: "1947", note: "..." }, and only then does serialization emit the mapping form.

Fields§

§value: String

The EDTF value.

§note: Option<String>

Optional opaque, uninterpreted text alongside the date. Preserved verbatim; never parsed, converted, or validated.

Implementations§

Source§

impl DateValue

Source

pub fn new(value: impl Into<String>) -> DateValue

Construct a DateValue with no note, from any string-like value.

Source

pub fn is_empty(&self) -> bool

Check if the date value is empty.

Source

pub fn parse(&self) -> RefDate

Parse the string as an EDTF date etc, or return the string as a literal.

Source

pub fn year(&self) -> String

Extract the year from the date.

Source

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

Extract the day from the date.

Source

pub fn is_uncertain(&self) -> bool

Check if the date is uncertain (has “?” qualifier).

Source

pub fn is_approximate(&self) -> bool

Check if the date is approximate (has “~” qualifier).

Source

pub fn is_range(&self) -> bool

Check if the date is a range (interval).

Source

pub fn is_open_range(&self) -> bool

Check if the range is open-ended (ends with “..”).

Source

pub fn time(&self) -> Option<Time>

Extract the time component from the date, if present.

Source

pub fn has_time(&self) -> bool

Check if the date has a time component.

Trait Implementations§

Source§

impl Clone for DateValue

Source§

fn clone(&self) -> DateValue

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for DateValue

Source§

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

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

impl Default for DateValue

Source§

fn default() -> DateValue

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for DateValue

Source§

fn deserialize<D>( deserializer: D, ) -> Result<DateValue, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for DateValue

Source§

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

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

impl From<&str> for DateValue

Source§

fn from(value: &str) -> DateValue

Converts to this type from the input type.
Source§

impl From<DateVariable> for DateValue

Source§

fn from(date: DateVariable) -> DateValue

Converts to this type from the input type.
Source§

impl From<String> for DateValue

Source§

fn from(value: String) -> DateValue

Converts to this type from the input type.
Source§

impl PartialEq for DateValue

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for DateValue

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for DateValue

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

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> Same for T

Source§

type Output = T

Should always be Self
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.