pub struct DateTimeRange { /* private fields */ }
Expand description

Represents a date-time range as two Option<chrono::DateTime<FixedOffset>> values. None means no upper or no lower bound for range is present.

Example

use chrono::{NaiveDate, NaiveTime, NaiveDateTime, DateTime, FixedOffset, TimeZone};
use dicom_core::value::DateTimeRange;

let offset = FixedOffset::west_opt(3600).unwrap();

let dtr = DateTimeRange::from_start_to_end(
    offset.from_local_datetime(&NaiveDateTime::new(
        NaiveDate::from_ymd_opt(2000, 5, 6).unwrap(),
        NaiveTime::from_hms_opt(15, 0, 0).unwrap()
    )).unwrap(),
    offset.from_local_datetime(&NaiveDateTime::new(
        NaiveDate::from_ymd_opt(2000, 5, 6).unwrap(),
        NaiveTime::from_hms_opt(16, 30, 0).unwrap()
    )).unwrap()
)?;

assert!(dtr.start().is_some());
assert!(dtr.end().is_some());

Implementations§

source§

impl DateTimeRange

source

pub fn from_start_to_end( start: DateTime<FixedOffset>, end: DateTime<FixedOffset> ) -> Result<DateTimeRange, Error>

Constructs a new DateTimeRange from two chrono::DateTime values monotonically ordered in time.

source

pub fn from_start(start: DateTime<FixedOffset>) -> DateTimeRange

Constructs a new DateTimeRange beginning with a chrono::DateTime value and no upper limit.

source

pub fn from_end(end: DateTime<FixedOffset>) -> DateTimeRange

Constructs a new DateTimeRange with no lower limit, ending with a chrono::DateTime value.

source

pub fn start(&self) -> Option<&DateTime<FixedOffset>>

Returns a reference to the lower bound of the range.

source

pub fn end(&self) -> Option<&DateTime<FixedOffset>>

Returns a reference to the upper bound of the range.

source

pub fn from_date_and_time_range( dr: DateRange, tr: TimeRange, offset: FixedOffset ) -> Result<DateTimeRange, Error>

For combined datetime range matching, this method constructs a DateTimeRange from a DateRange and a TimeRange.

Trait Implementations§

source§

impl Clone for DateTimeRange

source§

fn clone(&self) -> DateTimeRange

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for DateTimeRange

source§

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

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

impl Hash for DateTimeRange

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq<DateTimeRange> for DateTimeRange

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for DateTimeRange

source§

impl Eq for DateTimeRange

source§

impl StructuralEq for DateTimeRange

source§

impl StructuralPartialEq for DateTimeRange

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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> ToOwned for Twhere T: Clone,

§

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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.