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_test.cc b/aos/time/time_test.cc
index 6ff1085..38e389a 100644
--- a/aos/time/time_test.cc
+++ b/aos/time/time_test.cc
@@ -3,6 +3,7 @@
 #include <thread>
 
 #include "gtest/gtest.h"
+#include "glog/logging.h"
 
 #include "aos/macros.h"
 #include "aos/util/death_test_log_implementation.h"
@@ -202,6 +203,27 @@
     EXPECT_EQ(s.str(), "1969-12-27_00-00-10.995000000");
     EXPECT_EQ(realtime_clock::FromString(s.str()).value(), t);
   }
+
+  {
+    const realtime_clock::time_point t = realtime_clock::min_time;
+
+    std::stringstream s;
+    s << t;
+
+    EXPECT_EQ(s.str(), "1677-09-21_00-12-43.145224192");
+    EXPECT_EQ(realtime_clock::FromString(s.str()).value(), t);
+  }
+
+  {
+    const realtime_clock::time_point t =
+        realtime_clock::min_time + std::chrono::nanoseconds(999999999);
+
+    std::stringstream s;
+    s << t;
+
+    EXPECT_EQ(s.str(), "1677-09-21_00-12-44.145224191");
+    EXPECT_EQ(realtime_clock::FromString(s.str()).value(), t);
+  }
 }
 
 }  // namespace testing