Struct repr::adt::interval::Interval [−][src]
Expand description
An interval of time meant to express SQL intervals.
Obtained by parsing an INTERVAL '<value>' <unit> [TO <precision>]
.
Fields
months: i32
A possibly negative number of months for field types like YEAR
duration: i128
A timespan represented in nanoseconds.
Irrespective of values, duration
will not be carried over into
months
.
Implementations
Constructs a new Interval
with the specified units of time.
nanos
in excess of 999_999_999
are carried over into seconds.
Returns the total number of whole seconds in the Interval
’s duration.
Computes the millennium part of the interval.
The millennium part is the number of whole millennia in the interval. For example,
this function returns 3
for the interval 3400 years
.
Computes the century part of the interval.
The century part is the number of whole centuries in the interval. For example,
this function returns 3
for the interval 340 years
.
Computes the decade part of the interval.
The decade part is the number of whole decades in the interval. For example,
this function returns 3
for the interval 34 years
.
Computes the year part of the interval.
The year part is the number of whole years in the interval. For example,
this function returns 3
for the interval 3 years 4 months
.
Computes the quarter part of the interval.
The quarter part is obtained from taking the number of whole months modulo 12,
and assigning quarter #1 for months 0-2, #2 for 3-5, #3 for 6-8 and #4 for 9-11.
For example, this function returns 4
for the interval 11 months
.
Computes the month part of the interval.
The month part is the number of whole months in the interval, modulo 12.
For example, this function returns 4
for the interval 3 years 4 months
.
Computes the day part of the interval.
The day part is the number of whole days in the interval. For example,
this function returns 5
for the interval 5 days 4 hours 3 minutes 2.1 seconds
.
Computes the hour part of the interval.
The hour part is the number of whole hours in the interval, modulo 24.
For example, this function returns 4
for the interval 5 days 4 hours 3 minutes 2.1 seconds
.
Computes the minute part of the interval.
The minute part is the number of whole minutes in the interval, modulo
60. For example, this function returns 3
for the interval 5 days 4 hours 3 minutes 2.1 seconds
.
Computes the second part of the interval.
The second part is the number of fractional seconds in the interval, modulo 60.0.
Computes the second part of the interval displayed in milliseconds.
The second part is the number of fractional seconds in the interval, modulo 60.0.
Computes the second part of the interval displayed in microseconds.
The second part is the number of fractional seconds in the interval, modulo 60.0.
Computes the nanosecond part of the interval.
Computes the total number of seconds in the interval.
Truncate the “head” of the interval, removing all time units greater than f
.
Converts this Interval
’s duration into chrono::Duration
.
pub fn truncate_low_fields(
&mut self,
f: DateTimeField,
fsec_max_precision: Option<u64>
) -> Result<(), Error>
pub fn truncate_low_fields(
&mut self,
f: DateTimeField,
fsec_max_precision: Option<u64>
) -> Result<(), Error>
Trait Implementations
The SQL column type of this Rust type
Try to convert a Result whose Ok variant is a Datum into this native Rust type (Self). If it fails the error variant will contain the original result. Read more
Convert this Rust type into a Result containing a Datum, or an error
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
Format an interval in a human form
Example outputs:
- 1 year 2 months 5 days 03:04:00
- -1 year +5 days +18:59:29.3
- 00:00:00
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
impl RefUnwindSafe for Interval
impl UnwindSafe for Interval
Blanket Implementations
Mutably borrows from an owned value. Read more
Formats an object with the “alternative” format ({:#}
) and returns it.
Compare self to key
and return true
if they are equal.
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more