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
This is supported 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>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Ord for Timestamp
impl Ord for Timestamp
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>
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
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>
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
sourceimpl 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>
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
sourceimpl 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>
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
sourceimpl 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>
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
sourceimpl Round for Timestamp
impl Round for Timestamp
sourcefn round_century(self) -> Result<Self, Error>
fn round_century(self) -> Result<Self, Error>
If year is more than half of century, rounds to the first day of next century, else truncates. Read more
sourcefn round_year(self) -> Result<Self, Error>
fn round_year(self) -> Result<Self, Error>
If month is bigger than June, rounds to the first day of next year, else truncates. Read more
sourcefn round_iso_year(self) -> Result<Self, Error>
fn round_iso_year(self) -> Result<Self, Error>
If month is bigger than June, rounds to the first day of week in next year, else truncates. Read more
sourcefn round_quarter(self) -> Result<Self, Error>
fn round_quarter(self) -> Result<Self, Error>
Rounds up on the sixteenth day of the second month of the quarter, else truncates. Read more
sourcefn round_month(self) -> Result<Self, Error>
fn round_month(self) -> Result<Self, Error>
Rounds up on the sixteenth day of each month, else truncates. Read more
sourcefn round_week(self) -> Result<Self, Error>
fn round_week(self) -> Result<Self, Error>
Rounds up on the fifth day of each week, the same day of the week as the first day of the year, else truncates. Read more
sourcefn round_iso_week(self) -> Result<Self, Error>
fn round_iso_week(self) -> Result<Self, Error>
Rounds up on the fifth day of each week, Monday be the first day of week, else truncates. Read more
sourcefn round_month_start_week(self) -> Result<Self, Error>
fn round_month_start_week(self) -> Result<Self, Error>
Rounds up on the fifth day of each week, the same day of the week as the first day of the month, else truncates. Read more
sourcefn round_day(self) -> Result<Self, Error>
fn round_day(self) -> Result<Self, Error>
Rounds up at 12:00 of each day, else truncates. Read more
sourcefn round_sunday_start_week(self) -> Result<Self, Error>
fn round_sunday_start_week(self) -> Result<Self, Error>
Rounds up on the fifth day of each week, Sunday be the first day of week, else truncates. Read more
sourcefn round_hour(self) -> Result<Self, Error>
fn round_hour(self) -> Result<Self, Error>
Rounds up at half of each hour, else truncates. Read more
sourcefn round_minute(self) -> Result<Self, Error>
fn round_minute(self) -> Result<Self, Error>
Rounds up at half of each minute, else truncates. Read more
sourceimpl Trunc for Timestamp
impl Trunc for Timestamp
sourcefn trunc_century(self) -> Result<Self, Error>
fn trunc_century(self) -> Result<Self, Error>
Truncates to the first day of the century. Read more
sourcefn trunc_year(self) -> Result<Self, Error>
fn trunc_year(self) -> Result<Self, Error>
Truncates to the first day of the year. Read more
sourcefn trunc_iso_year(self) -> Result<Self, Error>
fn trunc_iso_year(self) -> Result<Self, Error>
Truncates to the first day of the first week in the year. Read more
sourcefn trunc_quarter(self) -> Result<Self, Error>
fn trunc_quarter(self) -> Result<Self, Error>
Truncates to the first day of the quarter. Read more
sourcefn trunc_month(self) -> Result<Self, Error>
fn trunc_month(self) -> Result<Self, Error>
Truncates to the first day of the month. Read more
sourcefn trunc_week(self) -> Result<Self, Error>
fn trunc_week(self) -> Result<Self, Error>
Truncates to the same day of the week as the first day of the year. Read more
sourcefn trunc_iso_week(self) -> Result<Self, Error>
fn trunc_iso_week(self) -> Result<Self, Error>
Truncates to the monday of the week. Read more
sourcefn trunc_month_start_week(self) -> Result<Self, Error>
fn trunc_month_start_week(self) -> Result<Self, Error>
Truncates to the same day of the week as the first day of the month. Read more
sourcefn trunc_sunday_start_week(self) -> Result<Self, Error>
fn trunc_sunday_start_week(self) -> Result<Self, Error>
Truncates to the sunday of the week. Read more
sourcefn trunc_hour(self) -> Result<Self, Error>
fn trunc_hour(self) -> Result<Self, Error>
Truncates to the hour. Read more
sourcefn trunc_minute(self) -> Result<Self, Error>
fn trunc_minute(self) -> Result<Self, Error>
Truncates to the minute. Read more
impl Copy for Timestamp
impl Eq for Timestamp
impl StructuralEq for Timestamp
impl StructuralPartialEq for Timestamp
Auto Trait Implementations
impl RefUnwindSafe for Timestamp
impl Send for Timestamp
impl Sync for Timestamp
impl Unpin for Timestamp
impl UnwindSafe for Timestamp
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> 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