commit | 0534df69fbd425588e4ee2662202e383f46e4110 | [log] [tgz] |
---|---|---|
author | Brian Silverman <brians> | Mon May 26 21:19:15 2014 -0700 |
committer | Brian Silverman <brians> | Mon May 26 21:19:15 2014 -0700 |
tree | d07f52d6fa95a9e89041eaa299e7b006740d1180 | |
parent | 7faaec70069d03054a4e2366356a2e2c027909f3 [diff] [blame] |
finished Time tests and fixed a corner case bug
diff --git a/aos/common/time.cc b/aos/common/time.cc index aa75eae..1c86811 100644 --- a/aos/common/time.cc +++ b/aos/common/time.cc
@@ -142,8 +142,8 @@ } Time &Time::operator%=(int32_t rhs) { nsec_ = ToNSec() % rhs; - const int wraps = nsec_ / kNSecInSec; - sec_ = wraps; + const int wraps = nsec_ / ((rhs / kNSecInSec + 1) * kNSecInSec); + sec_ = wraps + rhs / kNSecInSec; nsec_ -= kNSecInSec * wraps; if (nsec_ < 0) { nsec_ += kNSecInSec;