View Source PgInterop.Interval.Iso8601Formatter (electric v0.9.5)

Summary

Functions

Return a human readable string representing the duration, formatted according to ISO8601. Negative sections will be formatted accordingly, as does PG.

Functions

Return a human readable string representing the duration, formatted according to ISO8601. Negative sections will be formatted accordingly, as does PG.

Examples

iex> format(Interval.parse!("PT2S"))
"PT2S"

iex> format(Interval.parse!("PT2.0001S"))
"PT2.0001S"

iex> format(Interval.parse!("PT1M5S"))
"PT1M5S"

iex> format(Interval.parse!("PT1M5S"))
"PT1M5S"

iex> format(Interval.parse!("P45Y6M5DT21H12M34.590264S"))
"P45Y6M5DT21H12M34.590264S"

0-length interval is special-cased to render as "0S"

iex> format(%Interval{months: 0, days: 0, microseconds: 0})
"PT0S"