diff options
| author | Sean Griffin <sean@seantheprogrammer.com> | 2015-12-02 13:55:35 -0700 | 
|---|---|---|
| committer | Sean Griffin <sean@seantheprogrammer.com> | 2015-12-02 13:55:35 -0700 | 
| commit | a69bcd885b5cf18ba05e0f81c091d3132534115c (patch) | |
| tree | 251f341f91d3071efa8ccd2204a549b7cee7c957 /src/libstd/sys/unix | |
| parent | d5321f2abe7f6fadf8a3993b113ebb8ce9266fe9 (diff) | |
| download | rust-a69bcd885b5cf18ba05e0f81c091d3132534115c.tar.gz rust-a69bcd885b5cf18ba05e0f81c091d3132534115c.zip | |
Ensure two `SystemTime`s 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.
Diffstat (limited to 'src/libstd/sys/unix')
| -rw-r--r-- | src/libstd/sys/unix/time.rs | 2 | 
1 files changed, 1 insertions, 1 deletions
| diff --git a/src/libstd/sys/unix/time.rs b/src/libstd/sys/unix/time.rs index 75319ce962c..cc026b8fd10 100644 --- a/src/libstd/sys/unix/time.rs +++ b/src/libstd/sys/unix/time.rs @@ -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"); | 
