Skip to main content

normalize_duration

Function normalize_duration 

Source
pub fn normalize_duration(f: DurationFields) -> DurationParts
Expand description

Folds raw (possibly fractional, possibly negative) field values into PropertyValue::Duration’s normalized (months, days, seconds, nanos) form. The cascade only ever flows one direction – years into months, a fractional month’s remainder into days (via AVG_MONTH_DAYS – the only place that average is used), a fractional day’s remainder into seconds, sub-second fields into nanoseconds – matching Neo4j’s own documented normalization, verified line-by-line against every duration(...) example in the TCK’s Temporal1/Temporal2 feature files. Never the other direction (seconds never cascade into days – duration({hours: 40}) stays PT40H, not P1DT16H; a “day” isn’t a fixed number of hours once timezones/DST exist, so real Cypher never makes that assumption even though MarsDB’s own Date type is timezone-naive).