util: Implementing conversion to/from system_clock::TimePoint with customized format
Change-Id: I879cf2b3fe7402c4600e3536b02147333f5b9620
Refs: #1454
diff --git a/tests/util/test-time.cpp b/tests/util/test-time.cpp
index 2db2131..b1fbc71 100644
--- a/tests/util/test-time.cpp
+++ b/tests/util/test-time.cpp
@@ -20,9 +20,31 @@
BOOST_CHECK_GT(value, referenceTime);
BOOST_CHECK_EQUAL(time::toIsoString(referenceTime), "20140129T034247.032000");
- BOOST_CHECK_EQUAL(time::fromIsoString("20140129T034247.032000"), referenceTime);
+ BOOST_CHECK_EQUAL(time::toString(referenceTime), "2014-01-29 03:42:47");
+ BOOST_CHECK_EQUAL(time::toString(referenceTime), "2014-01-29 03:42:47");
+ // Unfortunately, not all systems has lv_LV locale installed :(
+ // BOOST_CHECK_EQUAL(time::toString(referenceTime, "%Y. gada %d. %B",
+ // std::locale("lv_LV.UTF-8")),
+ // "2014. gada 29. Janvāris");
+
+ BOOST_CHECK_EQUAL(time::toString(referenceTime, "%Y -- %d -- %B",
+ std::locale("C")),
+ "2014 -- 29 -- January");
+
+ BOOST_CHECK_EQUAL(time::fromIsoString("20140129T034247.032000"), referenceTime);
BOOST_CHECK_EQUAL(time::fromIsoString("20140129T034247.032000Z"), referenceTime);
+ BOOST_CHECK_EQUAL(time::fromString("2014-01-29 03:42:47"),
+ time::fromUnixTimestamp(time::seconds(1390966967)));
+
+ // Unfortunately, not all systems has lv_LV locale installed :(
+ // BOOST_CHECK_EQUAL(time::fromString("2014. gada 29. Janvāris", "%Y. gada %d. %B",
+ // std::locale("lv_LV.UTF-8")),
+ // time::fromUnixTimestamp(time::seconds(1390953600)));
+
+ BOOST_CHECK_EQUAL(time::fromString("2014 -- 29 -- January", "%Y -- %d -- %B",
+ std::locale("C")),
+ time::fromUnixTimestamp(time::seconds(1390953600)));
}
BOOST_AUTO_TEST_CASE(SteadyClock)