pub enum Edtf {
Date(Date),
DateTime(DateTime),
Interval(Interval),
Set(Set),
}Expand description
Any parsed EDTF expression.
Variants§
Date(Date)
A single date.
DateTime(DateTime)
A date with time of day (level 0 only).
Interval(Interval)
A time interval.
Set(Set)
A set of dates (level 2).
Implementations§
Source§impl Edtf
impl Edtf
Sourcepub fn relation(&self, other: &Edtf) -> Relations
pub fn relation(&self, other: &Edtf) -> Relations
The three-valued temporal relation between this expression and
other, computed over the two Edtf::bounds regions (see the
semantics note in this module’s documentation).
use edtf_core::{Edtf, Modality, Relation};
let a = Edtf::parse("1985~").unwrap();
let b = Edtf::parse("199X").unwrap();
assert_eq!(a.relation(&b).definite(), Some(Relation::Before));
let c = Edtf::parse("198X").unwrap();
let d = Edtf::parse("1985").unwrap();
// 198X may fall before, on, after or around 1985 — nothing asserted.
assert_eq!(c.relation(&d).definite(), None);
assert!(c.relation(&d).is_possible(Relation::Before));
assert!(c.relation(&d).is_possible(Relation::After));
assert!(c.relation(&d).is_possible(Relation::Contains));Source§impl Edtf
impl Edtf
Sourcepub fn parse(input: &str) -> Result<Self, ParseError>
pub fn parse(input: &str) -> Result<Self, ParseError>
Parse an EDTF string (levels 0–2, ISO 8601-2:2019 Annex A).
Sourcepub fn level(&self) -> u8
pub fn level(&self) -> u8
The minimum EDTF conformance level (0, 1 or 2) able to express this
value. Semantically equivalent spellings classify identically: e.g.
?1985-?04-?12 reports level 1 because 1985-04-12? means the same.
Sourcepub fn is_uncertain(&self) -> bool
pub fn is_uncertain(&self) -> bool
True if any component anywhere is marked uncertain (? or %).
Sourcepub fn is_approximate(&self) -> bool
pub fn is_approximate(&self) -> bool
True if any component anywhere is marked approximate (~ or %).
Sourcepub fn has_unspecified(&self) -> bool
pub fn has_unspecified(&self) -> bool
True if any component anywhere contains an unspecified digit (X).
Trait Implementations§
impl Eq for Edtf
impl StructuralPartialEq for Edtf
Auto Trait Implementations§
impl Freeze for Edtf
impl RefUnwindSafe for Edtf
impl Send for Edtf
impl Sync for Edtf
impl Unpin for Edtf
impl UnsafeUnpin for Edtf
impl UnwindSafe for Edtf
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