about summary refs log tree commit diff
path: root/src/libstd/sys
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-12-04 21:01:03 +0000
committerbors <bors@rust-lang.org>2015-12-04 21:01:03 +0000
commit55a4e050921a8f72cff28b0ab6e58376382daf32 (patch)
tree451ea4e9ca08a7f6898dfa40c01997f060bcba3f /src/libstd/sys
parent68c15be8b5a28297ae58ea030adf49f265e41127 (diff)
parent07471423a29bd4508a0552d4b9cfb104ca2a5928 (diff)
downloadrust-55a4e050921a8f72cff28b0ab6e58376382daf32.tar.gz
rust-55a4e050921a8f72cff28b0ab6e58376382daf32.zip
Auto merge of #30173 - sgrif:sg-fix-time-bug, r=alexcrichton
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')
-rw-r--r--src/libstd/sys/unix/time.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libstd/sys/unix/time.rs b/src/libstd/sys/unix/time.rs
index 75319ce962c..a07c30d9648 100644
--- a/src/libstd/sys/unix/time.rs
+++ b/src/libstd/sys/unix/time.rs
@@ -111,7 +111,7 @@ mod inner {
             // Nano calculations can't overflow because nanos are <1B which fit
             // in a u32.
             let mut usec = (other.subsec_nanos() / 1000) + self.t.tv_usec as u32;
-            if usec > USEC_PER_SEC as u32 {
+            if usec >= USEC_PER_SEC as u32 {
                 usec -= USEC_PER_SEC as u32;
                 secs = secs.checked_add(1).expect("overflow when adding \
                                                    duration to time");
@@ -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");