pub enum PreciseDateTime {
Naive(NaiveDateTime),
TimeZone(DateTime<FixedOffset>),
}
Expand description
An encapsulated date-time value which is precise to the microsecond and can either be time-zone aware or time-zone naive.
It is usually the outcome of converting a precise DICOM date-time value to a chrono date-time value.
Variants§
Naive(NaiveDateTime)
Naive date-time, with no time zone
TimeZone(DateTime<FixedOffset>)
Date-time with a time zone defined by a fixed offset
Implementations§
Source§impl PreciseDateTime
impl PreciseDateTime
Sourcepub fn as_datetime(&self) -> Option<&DateTime<FixedOffset>>
pub fn as_datetime(&self) -> Option<&DateTime<FixedOffset>>
Retrieves a reference to a chrono::DateTime<FixedOffset>
if the result is time-zone aware.
Sourcepub fn as_naive_datetime(&self) -> Option<&NaiveDateTime>
pub fn as_naive_datetime(&self) -> Option<&NaiveDateTime>
Retrieves a reference to a chrono::NaiveDateTime
only if the result is time-zone naive.
Sourcepub fn into_datetime(self) -> Option<DateTime<FixedOffset>>
pub fn into_datetime(self) -> Option<DateTime<FixedOffset>>
Moves out a chrono::DateTime<FixedOffset>
if the result is time-zone aware.
Sourcepub fn into_naive_datetime(self) -> Option<NaiveDateTime>
pub fn into_naive_datetime(self) -> Option<NaiveDateTime>
Moves out a chrono::NaiveDateTime
only if the result is time-zone naive.
Sourcepub fn to_naive_date(&self) -> NaiveDate
pub fn to_naive_date(&self) -> NaiveDate
Retrieves the time-zone naive date component of the precise date-time value.
§Panics
The time-zone aware variant uses DateTime
,
which internally stores the date and time in UTC with a NaiveDateTime
.
This method will panic if the offset from UTC would push the local date
outside of the representable range of a NaiveDate
.
Sourcepub fn to_naive_time(&self) -> NaiveTime
pub fn to_naive_time(&self) -> NaiveTime
Retrieves the time component of the precise date-time value.
Sourcepub fn has_time_zone(&self) -> bool
pub fn has_time_zone(&self) -> bool
Returns true
if the result is time-zone aware.
Trait Implementations§
Source§impl Clone for PreciseDateTime
impl Clone for PreciseDateTime
Source§fn clone(&self) -> PreciseDateTime
fn clone(&self) -> PreciseDateTime
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for PreciseDateTime
impl Debug for PreciseDateTime
Source§impl Hash for PreciseDateTime
impl Hash for PreciseDateTime
Source§impl PartialEq for PreciseDateTime
impl PartialEq for PreciseDateTime
Source§impl PartialOrd for PreciseDateTime
impl PartialOrd for PreciseDateTime
The partial ordering for PreciseDateTime
is defined by the partial ordering of matching variants
(Naive
with Naive
, TimeZone
with TimeZone
).
Any other comparison cannot be defined,
and therefore will always return None
.
impl Copy for PreciseDateTime
impl Eq for PreciseDateTime
impl StructuralPartialEq for PreciseDateTime
Auto Trait Implementations§
impl Freeze for PreciseDateTime
impl RefUnwindSafe for PreciseDateTime
impl Send for PreciseDateTime
impl Sync for PreciseDateTime
impl Unpin for PreciseDateTime
impl UnwindSafe for PreciseDateTime
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more