Skip to main content

format_interval_kinded

Function format_interval_kinded 

Source
pub fn format_interval_kinded(
    months: i32,
    days: i32,
    micros: i64,
    kind: IntervalKind,
) -> String
Expand description

format_interval under an IntervalStyle (PG18 differential truth):

  • sql_standard — pure year-month 1-2 / -1-2; pure day-time 1 0:00:00 (sign on the leading field, time fields absolute; time-only 2:00:00 / -0:00:01); a mix of year-month and day-time classes (or mixed signs) is non-conforming and prints every part explicitly signed: +1-2 +3 +4:05:06, +0-1 -1 +0:00:00; zero → 0.
  • iso_8601 — P[nY][nM][nD][T[nH][nM][nS]], each field individually signed, zero → PT0S.
  • postgres_verbose — @ + years/mons/days/hours/mins/secs fields; when the interval compares below zero every field is negated and ago is appended; zero → @ 0. Render an interval that may be infinite.

v7.38.19 — PostgreSQL 18.4 renders the two infinities as the words infinity and -infinity, in every interval style, and reads them back ('infinity'::text::interval round-trips). 'inf' is NOT accepted, which is the one place interval differs from float here.