pub struct DateTime { /* private fields */ }
Expand description
A date/time value with microsecond precision.
This timestamp does not carry any explicit time zone information. Users are responsible for applying the provided conversion functions consistently. Internally the time zone is assumed to be UTC, which is also used implicitly for JSON serialization.
All constructors and conversions are provided as explicit
functions and not by implementing any From
/Into
traits
to prevent unintended usage.
Implementations
sourceimpl DateTime
impl DateTime
sourcepub const fn from_timestamp_secs(seconds: i64) -> Self
pub const fn from_timestamp_secs(seconds: i64) -> Self
Create new from UNIX timestamp in seconds
sourcepub const fn from_timestamp_millis(milliseconds: i64) -> Self
pub const fn from_timestamp_millis(milliseconds: i64) -> Self
Create new from UNIX timestamp in milliseconds
sourcepub const fn from_timestamp_micros(microseconds: i64) -> Self
pub const fn from_timestamp_micros(microseconds: i64) -> Self
Create new from UNIX timestamp in microseconds.
sourcepub const fn from_utc(dt: OffsetDateTime) -> Self
pub const fn from_utc(dt: OffsetDateTime) -> Self
Create new from OffsetDateTime
The given date/time is converted to UTC and the actual time zone is discarded.
sourcepub fn from_primitive(dt: PrimitiveDateTime) -> Self
pub fn from_primitive(dt: PrimitiveDateTime) -> Self
Create new from PrimitiveDateTime
Implicitly assumes that the given date/time is in UTC!
Otherwise the original value must only be reobtained with
Self::into_primitive()
.
sourcepub const fn into_timestamp_secs(self) -> i64
pub const fn into_timestamp_secs(self) -> i64
Convert to UNIX timestamp in seconds.
sourcepub const fn into_timestamp_millis(self) -> i64
pub const fn into_timestamp_millis(self) -> i64
Convert to UNIX timestamp in milliseconds.
sourcepub const fn into_timestamp_micros(self) -> i64
pub const fn into_timestamp_micros(self) -> i64
Convert to UNIX timestamp in microseconds.
sourcepub fn into_utc(self) -> OffsetDateTime
pub fn into_utc(self) -> OffsetDateTime
Convert to UTC OffsetDateTime
sourcepub fn into_offset(self, offset: UtcOffset) -> OffsetDateTime
pub fn into_offset(self, offset: UtcOffset) -> OffsetDateTime
Convert to OffsetDateTime
with the given time zone
sourcepub fn into_primitive(self) -> PrimitiveDateTime
pub fn into_primitive(self) -> PrimitiveDateTime
Convert to PrimitiveDateTime
without any time zone
The value should have been constructed with Self::from_primitive()
.
Otherwise the time zone is implicitly assumed to be UTC.
Trait Implementations
sourceimpl MonotonicallyMappableToU64 for DateTime
impl MonotonicallyMappableToU64 for DateTime
sourceimpl Ord for DateTime
impl Ord for DateTime
sourceimpl PartialOrd<DateTime> for DateTime
impl PartialOrd<DateTime> for DateTime
impl Copy for DateTime
impl Eq for DateTime
impl StructuralEq for DateTime
impl StructuralPartialEq for DateTime
Auto Trait Implementations
impl RefUnwindSafe for DateTime
impl Send for DateTime
impl Sync for DateTime
impl Unpin for DateTime
impl UnwindSafe for DateTime
Blanket Implementations
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstablefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
sourcefn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read moresourcefn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read moresourcefn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read moresourcefn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read moresourceimpl<T> DowncastSync for Twhere
T: Any + Send + Sync,
impl<T> DowncastSync for Twhere
T: Any + Send + Sync,
sourcefn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send + 'static>
fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send + 'static>
Arc<Trait>
(where Trait: Downcast
) to Arc<Any>
. Arc<Any>
can then be
further downcast
into Arc<ConcreteType>
where ConcreteType
implements Trait
. Read more