Skip to main content

checked_add_with_leapsecond

Function checked_add_with_leapsecond 

Source
pub fn checked_add_with_leapsecond(
    lhs: &NaiveDateTime,
    rhs: &FixedOffset,
) -> Option<NaiveDateTime>
Expand description

Adds a fixed offset to lhs, returning None on overflow.

chrono’s own NaiveDateTime + FixedOffset panics on overflow, so this is the only safe way to shift a timestamp that may sit at the edge of chrono’s range. Beyond the overflow check it also normalizes a leap second that the shift moves off :59, see the note in the body.