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

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

Performs the conversion.

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

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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.