Skip to main content

split_nanos_to_micros

Function split_nanos_to_micros 

Source
fn split_nanos_to_micros(nanos: u32) -> (bool, u32)
Expand description

Splits a sub-second nanosecond count into a whole-second carry and the microsecond fraction to render, rounding half away from zero.

The returned fraction is always below one second, so it can never be written as a fractional field of more than six digits. Only a nanosecond count of .9999995 or more produces a carry.

chrono spells a leap second as a nanosecond count of one second or more, and its %S already accounts for that, rendering 60 on a second-of-minute of 59 and folding into the next second elsewhere. The leap second is therefore already in the seconds field and only the part below one second is ours to write.