pub struct DateTime { /* private fields */ }
Expand description
A date/time value with second 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_unix_timestamp(unix_timestamp: i64) -> Self
pub const fn from_unix_timestamp(unix_timestamp: i64) -> Self
Create new from UNIX timestamp
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 const fn from_primitive(dt: PrimitiveDateTime) -> Self
pub const 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_unix_timestamp(self) -> i64
pub const fn into_unix_timestamp(self) -> i64
Convert to UNIX timestamp
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 FastValue for DateTime
impl FastValue for DateTime
sourcefn fast_field_cardinality(field_type: &FieldType) -> Option<Cardinality>
fn fast_field_cardinality(field_type: &FieldType) -> Option<Cardinality>
Returns the fast field cardinality that can be extracted from the given
FieldType
. Read more
sourceimpl Ord for DateTime
impl Ord for DateTime
sourceimpl PartialOrd<DateTime> for DateTime
impl PartialOrd<DateTime> for DateTime
sourcefn partial_cmp(&self, other: &DateTime) -> Option<Ordering>
fn partial_cmp(&self, other: &DateTime) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
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>
Convert 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 more
sourcefn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
sourcefn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
sourcefn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more
sourceimpl<T> DowncastSync for T where
T: Any + Send + Sync,
impl<T> DowncastSync for T where
T: Any + Send + Sync,
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more