Struct tantivy_common::DateTime
source · 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) -> 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_timestamp_nanos(nanoseconds: i64) -> Self
pub const fn from_timestamp_nanos(nanoseconds: i64) -> Self
Create new from UNIX timestamp in nanoseconds.
sourcepub fn from_utc(dt: OffsetDateTime) -> Self
pub 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 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) -> Self
pub fn truncate(self, precision: DateTimePrecision) -> Self
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<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl Ord for DateTime
impl Ord for DateTime
source§impl PartialEq for DateTime
impl PartialEq for DateTime
source§impl PartialOrd for DateTime
impl PartialOrd for DateTime
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more