Struct dicom_core::value::partial::DicomDate [−][src]
pub struct DicomDate(_);Expand description
Represents a Dicom Date value with a partial precision, where some date components may be missing.
Unlike Rust’s chrono::NaiveDate, it does not allow for negative years.
DicomDate implements AsRange trait, enabling to retrieve specific
chrono::NaiveDate values.
Example
use chrono::NaiveDate;
use dicom_core::value::{DicomDate, AsRange};
let date = DicomDate::from_y(1492)?;
assert_eq!(
date.latest()?,
NaiveDate::from_ymd(1492,12,31)
);
let date = DicomDate::try_from(&NaiveDate::from_ymd(1900, 5, 3))?;
// conversion from chrono value leads to a precise value
assert_eq!(date.is_precise(), true);
assert_eq!(date.to_string(), "1900-05-03");Implementations
Constructs a new DicomDate with year precision
(YYYY)
Constructs a new DicomDate with year and month precision
(YYYYMM)
Constructs a new DicomDate with a year, month and day precision
(YYYYMMDD)
Retrieves a dicom encoded string representation of the value.
Retrieves a chrono::NaiveDate if value is precise.
Trait Implementations
Returns the earliest possible chrono value from a partial precision structure.
Missing components default to 1 (days, months) or 0 (hours, minutes, …)
If structure contains invalid combination of DateComponents, it fails. Read more
Returns the latest possible chrono value from a partial precision structure.
If structure contains invalid combination of DateComponents, it fails. Read more
Returns a tuple of the earliest and latest possible value from a partial precision structure.
Returns a corresponding chrono value, if the partial precision structure has full accuracy.
Returns true, if partial precision structure has maximum possible accuracy.
For fraction of a second, full 6 digits are required for the value to be precise. Read more
Auto Trait Implementations
impl RefUnwindSafe for DicomDate
impl UnwindSafe for DicomDate
Blanket Implementations
Mutably borrows from an owned value. Read more