Skip to main content

format_duration

Function format_duration 

Source
pub fn format_duration(
    months: i64,
    days: i64,
    seconds: i64,
    nanos: i32,
) -> String
Expand description

Renders (months, days, seconds, nanos) as MarsDB’s canonical ISO-8601 duration text – always in PnYnMnDTnHnMn.fS order (never W, even though duration({weeks: 1}) accepts it as an input unit – weeks fold into days during normalization and never come back out, matching every toString(duration(...)) example in the TCK). Each component is a straight divmod of the sign-independent whole – a negative months/days/seconds prints its own - (P-6M-15D...), not one shared sign prefix, matching the TCK’s mixed- sign examples exactly (see Temporal8’s duration-subtraction table).