Struct repr::adt::interval::Interval[][src]

pub struct Interval {
    pub months: i32,
    pub duration: i128,
}
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.0 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.0 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.0 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.0 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.0 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.0 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.0 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.0 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.0 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.

Truncate the “tail” of the interval, removing all time units less than f.

Arguments
  • f: Round the interval down to the specified time unit.
  • fsec_max_precision: If Some(x), keep only x places of nanosecond precision. Must be (0,6).
Errors
  • If fsec_max_precision is not None or within (0,6).

Trait Implementations

The SQL column type of this Rust type

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Whether this Rust type can represent NULL values

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

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

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

Formats the value using the given formatter. Read more

Performs the conversion.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

The resulting type after applying the - operator.

Performs the unary - operation. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Formats an object with the “alternative” format ({:#}) and returns it.

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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