pub enum Interval {
Month(i32),
Microsecond(i64),
}Expand description
Represents a time interval, which can be either in months or microseconds.
The Interval type is divided into two variants: Interval::Month and Interval::Microsecond.
This distinction is made because the conversion between months and days is not consistent.
While a year can be clearly calculated as 12 months in the solar calendar,
a month can vary in the number of days (28, 30, or 31 days).
To ensure precise calculations and comparisons, intervals are represented in the smallest
unambiguous units: Month for month-based intervals and Microsecond for microsecond-based intervals.
Comparisons are only allowed within the same unit type to avoid ambiguity.
For more details on how comparisons are implemented, refer to the Interval::partial_cmp trait.
Variants§
Implementations§
Source§impl Interval
impl Interval
pub fn unary_minus(&self) -> Self
pub fn add(&self, other: &Interval) -> Result<Self>
pub fn subtract(&self, other: &Interval) -> Result<Self>
pub fn add_date(&self, date: &NaiveDate) -> Result<NaiveDateTime>
pub fn subtract_from_date(&self, date: &NaiveDate) -> Result<NaiveDateTime>
pub fn add_timestamp(&self, timestamp: &NaiveDateTime) -> Result<NaiveDateTime>
pub fn subtract_from_timestamp( &self, timestamp: &NaiveDateTime, ) -> Result<NaiveDateTime>
pub fn add_time(&self, time: &NaiveTime) -> Result<NaiveTime>
pub fn subtract_from_time(&self, time: &NaiveTime) -> Result<NaiveTime>
pub fn years(years: i32) -> Self
pub fn months(months: i32) -> Self
pub fn extract(&self, field: &DateTimeField) -> Result<Value>
pub fn days(days: i32) -> Self
pub fn hours(hours: i32) -> Self
pub fn minutes(minutes: i32) -> Self
pub fn seconds(seconds: i64) -> Self
pub fn milliseconds(milliseconds: i64) -> Self
pub fn microseconds(microseconds: i64) -> Self
pub fn try_from_str( value: &str, leading_field: Option<DateTimeField>, last_field: Option<DateTimeField>, ) -> Result<Self>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Interval
impl<'de> Deserialize<'de> for Interval
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl IntoParamLiteral for Interval
impl IntoParamLiteral for Interval
Source§fn into_param_literal(self) -> ParamLiteral
fn into_param_literal(self) -> ParamLiteral
Converts the value into a
ParamLiteral so it can be bound as a query parameter.Source§impl PartialOrd for Interval
impl PartialOrd for Interval
impl Copy for Interval
impl Eq for Interval
impl StructuralPartialEq for Interval
Auto Trait Implementations§
impl Freeze for Interval
impl RefUnwindSafe for Interval
impl Send for Interval
impl Sync for Interval
impl Unpin for Interval
impl UnwindSafe for Interval
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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
Compare self to
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>
Converts
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>
Converts
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