Skip to main content

roll_over_leap_second

Function roll_over_leap_second 

Source
fn roll_over_leap_second(dt: NaiveDateTime) -> Option<NaiveDateTime>
Expand description

Postgres normalizes a parsed :60 second by rolling it into the next minute. chrono instead keeps a leap-second representation (nanos >= 1e9) that sorts before the following second while epoch-style conversions count it at or past that second, which breaks the monotonicity contracts persist filter pushdown derives ranges with. Roll it over at the parse boundary so the leap representation never enters a parsed timestamp. TIME keeps the leap representation: rolling it over would wrap to 00:00:00 and reverse its ordering, and the whole-second leap time is harmless.

Returns None when the rollover overflows chrono’s range (a leap second on the maximum date), which callers report as out of range.