pub struct DateTime { /* private fields */ }Expand description
A date/time value with nanoseconds 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§
Source§impl DateTime
impl DateTime
Sourcepub const fn from_timestamp_secs(seconds: i64) -> DateTime
pub const fn from_timestamp_secs(seconds: i64) -> DateTime
Create new from UNIX timestamp in seconds
Sourcepub const fn from_timestamp_millis(milliseconds: i64) -> DateTime
pub const fn from_timestamp_millis(milliseconds: i64) -> DateTime
Create new from UNIX timestamp in milliseconds
Sourcepub const fn from_timestamp_micros(microseconds: i64) -> DateTime
pub const fn from_timestamp_micros(microseconds: i64) -> DateTime
Create new from UNIX timestamp in microseconds.
Sourcepub const fn from_timestamp_nanos(nanoseconds: i64) -> DateTime
pub const fn from_timestamp_nanos(nanoseconds: i64) -> DateTime
Create new from UNIX timestamp in nanoseconds.
Sourcepub fn from_utc(dt: OffsetDateTime) -> DateTime
pub fn from_utc(dt: OffsetDateTime) -> DateTime
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) -> DateTime
pub fn from_primitive(dt: PrimitiveDateTime) -> DateTime
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 const fn into_timestamp_nanos(self) -> i64
pub const fn into_timestamp_nanos(self) -> i64
Convert to UNIX timestamp in nanoseconds.
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.
Sourcepub fn truncate(self, precision: DateTimePrecision) -> DateTime
pub fn truncate(self, precision: DateTimePrecision) -> DateTime
Truncates the microseconds value to the corresponding precision.
Trait Implementations§
Source§impl BinarySerializable for DateTime
impl BinarySerializable for DateTime
Source§impl<'de> Deserialize<'de> for DateTime
impl<'de> Deserialize<'de> for DateTime
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<DateTime, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<DateTime, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl From<DateTime> for OwnedValue
impl From<DateTime> for OwnedValue
Source§fn from(dt: DateTime) -> OwnedValue
fn from(dt: DateTime) -> OwnedValue
Source§impl From<DateTime> for ReferenceValueLeaf<'_>
impl From<DateTime> for ReferenceValueLeaf<'_>
Source§impl HasAssociatedColumnType for DateTime
impl HasAssociatedColumnType for DateTime
fn column_type() -> ColumnType
fn default_value() -> DateTime
Source§impl Ord for DateTime
impl Ord for DateTime
Source§impl PartialOrd for DateTime
impl PartialOrd for DateTime
Source§impl Serialize for DateTime
impl Serialize for DateTime
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Source§impl<'a> Value<'a> for &'a DateTime
impl<'a> Value<'a> for &'a DateTime
Source§type ArrayIter = Empty<&'a DateTime>
type ArrayIter = Empty<&'a DateTime>
Source§type ObjectIter = Empty<(&'a str, &'a DateTime)>
type ObjectIter = Empty<(&'a str, &'a DateTime)>
Source§fn as_value(&self) -> ReferenceValue<'a, Self>
fn as_value(&self) -> ReferenceValue<'a, Self>
Source§fn as_leaf(&self) -> Option<ReferenceValueLeaf<'a>>
fn as_leaf(&self) -> Option<ReferenceValueLeaf<'a>>
Source§fn as_str(&self) -> Option<&'a str>
fn as_str(&self) -> Option<&'a str>
Source§fn as_u64(&self) -> Option<u64>
fn as_u64(&self) -> Option<u64>
Source§fn as_i64(&self) -> Option<i64>
fn as_i64(&self) -> Option<i64>
Source§fn as_f64(&self) -> Option<f64>
fn as_f64(&self) -> Option<f64>
Source§fn as_datetime(&self) -> Option<DateTime>
fn as_datetime(&self) -> Option<DateTime>
Source§fn as_ip_addr(&self) -> Option<Ipv6Addr>
fn as_ip_addr(&self) -> Option<Ipv6Addr>
Source§fn as_bool(&self) -> Option<bool>
fn as_bool(&self) -> Option<bool>
Source§fn as_pre_tokenized_text(&self) -> Option<Box<PreTokenizedString>>
fn as_pre_tokenized_text(&self) -> Option<Box<PreTokenizedString>>
Source§fn as_bytes(&self) -> Option<&'a [u8]>
fn as_bytes(&self) -> Option<&'a [u8]>
Source§fn as_facet(&self) -> Option<&'a str>
fn as_facet(&self) -> Option<&'a str>
Source§fn as_array(&self) -> Option<Self::ArrayIter>
fn as_array(&self) -> Option<Self::ArrayIter>
Source§fn as_object(&self) -> Option<Self::ObjectIter>
fn as_object(&self) -> Option<Self::ObjectIter>
Source§impl ValueDeserialize for DateTime
impl ValueDeserialize for DateTime
Source§fn deserialize<'de, D>(deserializer: D) -> Result<Self, DeserializeError>where
D: ValueDeserializer<'de>,
fn deserialize<'de, D>(deserializer: D) -> Result<Self, DeserializeError>where
D: ValueDeserializer<'de>,
impl Copy for DateTime
impl Eq for DateTime
impl StructuralPartialEq for DateTime
Auto Trait Implementations§
impl Freeze for DateTime
impl RefUnwindSafe for DateTime
impl Send for DateTime
impl Sync for DateTime
impl Unpin for DateTime
impl UnwindSafe for DateTime
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§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn 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.Source§fn 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.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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