Handle printing realtime_clock::min_time correctly
We were printing it in the future, not the past. This was due to an
underflow in the nanoseconds -> seconds calculation. Fix that to make
the error a lot more meaningful.
Change-Id: Ie0cd6281013f12f0362cd4acf834c167f75c308a
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/aos/time/time.cc b/aos/time/time.cc
index 697770c..0a633ef 100644
--- a/aos/time/time.cc
+++ b/aos/time/time.cc
@@ -146,8 +146,9 @@
std::tm tm;
std::chrono::seconds seconds =
now < realtime_clock::epoch()
- ? std::chrono::duration_cast<std::chrono::seconds>(
- now.time_since_epoch() - std::chrono::nanoseconds(999999999))
+ ? (std::chrono::duration_cast<std::chrono::seconds>(
+ now.time_since_epoch() + std::chrono::nanoseconds(1)) -
+ std::chrono::seconds(1))
: std::chrono::duration_cast<std::chrono::seconds>(
now.time_since_epoch());