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 the value is precise up to the day of the month.

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 the maximum possible accuracy. For fraction of a second, the full 6 digits are required for the value to be precise. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.