util: Fix conversion of large dates from strings to internal type

Change-Id: I13f8d41892dedd0d2feef131a0f09ae5939d124b
Refs: #4478
diff --git a/tests/unit-tests/util/time.t.cpp b/tests/unit-tests/util/time.t.cpp
index 58fdfae..b2988f2 100644
--- a/tests/unit-tests/util/time.t.cpp
+++ b/tests/unit-tests/util/time.t.cpp
@@ -82,9 +82,11 @@
 {
   auto value = fromUnixTimestamp(milliseconds(1390966967032LL));
   BOOST_CHECK_EQUAL(toIsoString(value), "20140129T034247.032000");
+  BOOST_CHECK_EQUAL(fromIsoString("20140129T034247.032000"), value);
 
-  value += days(365 * 100 + 25 - 1); // 36524 days
+  value += 36524_days;
   BOOST_CHECK_EQUAL(toIsoString(value), "21140129T034247.032000");
+  BOOST_CHECK_EQUAL(fromIsoString("21140129T034247.032000"), value);
 }
 
 BOOST_AUTO_TEST_CASE(Literals)
@@ -115,6 +117,16 @@
   BOOST_CHECK_EQUAL(5.5_ns, 0.0055_us);
 }
 
+BOOST_AUTO_TEST_CASE(Year2038)
+{
+  auto year2042 = fromIsoString("20420101T000001.042000");
+  auto year2010 = fromIsoString("20100101T000001.042000");
+
+  BOOST_CHECK_EQUAL(to_string(year2010), "1262304001042000000 nanoseconds since Jan 1, 1970");
+  BOOST_CHECK_EQUAL(to_string(year2042), "2272147201042000000 nanoseconds since Jan 1, 1970");
+  BOOST_CHECK_GT(year2042, year2010);
+}
+
 BOOST_AUTO_TEST_SUITE_END() // TestTime
 BOOST_AUTO_TEST_SUITE_END() // Util