Ensure two SystemTimes are equal when nanos add to exactly 1B
Currently if you add a duration which should lead to 0 nanos and 1 additional second, we end up with no additional seconds, and 1000000000 nanos.
This commit is contained in:
@@ -330,7 +330,7 @@ mod inner {
|
||||
// Nano calculations can't overflow because nanos are <1B which fit
|
||||
// in a u32.
|
||||
let mut nsec = other.subsec_nanos() + self.t.tv_nsec as u32;
|
||||
if nsec > NSEC_PER_SEC as u32 {
|
||||
if nsec >= NSEC_PER_SEC as u32 {
|
||||
nsec -= NSEC_PER_SEC as u32;
|
||||
secs = secs.checked_add(1).expect("overflow when adding \
|
||||
duration to time");
|
||||
|
||||
Reference in New Issue
Block a user