Struct sqldatetime::Timestamp
source · [−]#[repr(transparent)]pub struct Timestamp(_);Expand description
Timestamp represents a valid time at a valid Gregorian date.
This is an SQL TIMESTAMP value, with the specification of fractional seconds to a precision of microseconds.
Implementations
sourceimpl Timestamp
impl Timestamp
sourcepub const MIN: Self = _
pub const MIN: Self = _
The smallest timestamp that can be represented by Date, i.e. 0001-01-01 00:00:00.000000.
sourcepub const MAX: Self = _
pub const MAX: Self = _
The largest timestamp that can be represented by Date, i.e. 9999-12-31 23:59:59.999999.
sourcepub const fn new(date: Date, time: Time) -> Self
pub const fn new(date: Date, time: Time) -> Self
Creates a new Timestamp from a date and a time.
sourcepub const unsafe fn from_usecs_unchecked(usecs: i64) -> Self
pub const unsafe fn from_usecs_unchecked(usecs: i64) -> Self
Creates a Timestamp from the given microseconds from Unix Epoch without checking validity.
Safety
This function is unsafe because the microsecond value is not checked for validity! Before using it, check that the value is correct.
sourcepub fn format<S: AsRef<str>>(self, fmt: S) -> Result<impl Display, Error>
pub fn format<S: AsRef<str>>(self, fmt: S) -> Result<impl Display, Error>
Formats Timestamp by given format string.
sourcepub fn parse<S1: AsRef<str>, S2: AsRef<str>>(
input: S1,
fmt: S2
) -> Result<Self, Error>
pub fn parse<S1: AsRef<str>, S2: AsRef<str>>(
input: S1,
fmt: S2
) -> Result<Self, Error>
Parses Timestamp from given string and format.
sourcepub const fn try_from_usecs(usecs: i64) -> Result<Self, Error>
pub const fn try_from_usecs(usecs: i64) -> Result<Self, Error>
Creates a Timestamp from the given microseconds from Unix Epoch
sourcepub const fn add_interval_dt(
self,
interval: IntervalDT
) -> Result<Timestamp, Error>
pub const fn add_interval_dt(
self,
interval: IntervalDT
) -> Result<Timestamp, Error>
Timestamp adds IntervalDT
sourcepub fn add_interval_ym(self, interval: IntervalYM) -> Result<Timestamp, Error>
pub fn add_interval_ym(self, interval: IntervalYM) -> Result<Timestamp, Error>
Timestamp adds IntervalYM
sourcepub const fn sub_date(self, date: Date) -> IntervalDT
pub const fn sub_date(self, date: Date) -> IntervalDT
Timestamp subtracts Date
sourcepub const fn sub_timestamp(self, timestamp: Timestamp) -> IntervalDT
pub const fn sub_timestamp(self, timestamp: Timestamp) -> IntervalDT
Timestamp subtracts Timestamp
sourcepub const fn sub_interval_dt(
self,
interval: IntervalDT
) -> Result<Timestamp, Error>
pub const fn sub_interval_dt(
self,
interval: IntervalDT
) -> Result<Timestamp, Error>
Timestamp subtracts IntervalDT
sourcepub fn sub_interval_ym(self, interval: IntervalYM) -> Result<Timestamp, Error>
pub fn sub_interval_ym(self, interval: IntervalYM) -> Result<Timestamp, Error>
Timestamp subtracts IntervalYM
sourcepub fn last_day_of_month(self) -> Timestamp
pub fn last_day_of_month(self) -> Timestamp
Gets the last day in month of Timestamp.
sourceimpl Timestamp
impl Timestamp
sourcepub const fn oracle_sub_date(self, date: Date) -> IntervalDT
pub const fn oracle_sub_date(self, date: Date) -> IntervalDT
Timestamp subtracts Date
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Timestamp
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Timestamp
serde only.sourcefn 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>,
sourceimpl Ord for Timestamp
impl Ord for Timestamp
1.21.0 · sourceconst fn max(self, other: Self) -> Self
const fn max(self, other: Self) -> Self
1.21.0 · sourceconst fn min(self, other: Self) -> Self
const fn min(self, other: Self) -> Self
1.50.0 · sourceconst fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
const fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
sourceimpl PartialOrd<Date> for Timestamp
impl PartialOrd<Date> for Timestamp
sourcefn partial_cmp(&self, other: &Date) -> Option<Ordering>
fn partial_cmp(&self, other: &Date) -> Option<Ordering>
1.0.0 · sourceconst fn le(&self, other: &Rhs) -> bool
const fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moresourceimpl PartialOrd<Date> for Timestamp
impl PartialOrd<Date> for Timestamp
sourcefn partial_cmp(&self, other: &Date) -> Option<Ordering>
fn partial_cmp(&self, other: &Date) -> Option<Ordering>
1.0.0 · sourceconst fn le(&self, other: &Rhs) -> bool
const fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moresourceimpl PartialOrd<Timestamp> for Date
impl PartialOrd<Timestamp> for Date
sourcefn partial_cmp(&self, other: &Timestamp) -> Option<Ordering>
fn partial_cmp(&self, other: &Timestamp) -> Option<Ordering>
1.0.0 · sourceconst fn le(&self, other: &Rhs) -> bool
const fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moresourceimpl PartialOrd<Timestamp> for Date
impl PartialOrd<Timestamp> for Date
sourcefn partial_cmp(&self, other: &Timestamp) -> Option<Ordering>
fn partial_cmp(&self, other: &Timestamp) -> Option<Ordering>
1.0.0 · sourceconst fn le(&self, other: &Rhs) -> bool
const fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moresourceimpl PartialOrd<Timestamp> for Timestamp
impl PartialOrd<Timestamp> for Timestamp
sourcefn partial_cmp(&self, other: &Timestamp) -> Option<Ordering>
fn partial_cmp(&self, other: &Timestamp) -> Option<Ordering>
1.0.0 · sourceconst fn le(&self, other: &Rhs) -> bool
const fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read more