pg_value/interval
Types
Values
pub fn add(left: Interval, right: Interval) -> Interval
Returns an Interval with the summed values of each provided Interval
pub fn decoder() -> decode.Decoder(Interval)
Returns a decoder that decodes the dynamic value returned by
pg_value.decode when decoding an PostgresSQL Interval.
pub fn microseconds(microseconds: Int) -> Interval
Returns an Interval with the provided number of microseconds
pub fn months(months: Int) -> Interval
Returns an Interval with the provided number of months
pub fn seconds(seconds: Int) -> Interval
Returns an Interval with the provided number of seconds
pub fn to_iso8601_string(interval: Interval) -> String
Converts an interval to an ISO8601
formatted string. This function avoids converting the Interval’s units, except for
when the number of microseconds includes whole seconds. If more than 1_000_000
microseconds are provided, whole seconds will be derived from the microseconds value.
The remaining microseconds will be appended as a decimal in the formatted string.
Interval(months: 14, days: 0, seconds: 86430, microseconds: 0)
will be formatted as “P14MT86430S” rather than subdividing months into years
or seconds into days and formatting the string as e.g. “P1Y2M1DT30S”.
Interval(months: 0, days: 0, seconds: 10, microseconds: 1_200_000) will be
formatted as “PT11.2S”
PostgreSQL intervals are signed. The seconds and microseconds components are
normalized to a single combined signed value, so e.g.
Interval(0, 0, 0, -500_000) is formatted as “PT-0.5S” and
Interval(0, 0, 10, -200_000) as “PT9.8S”.
Negative month/day components are emitted directly, e.g. “P-1M”. This is accepted by PostgreSQL’s interval parser but is not strictly valid ISO 8601, which has no representation for negative individual components.