Support micro and milli resolution on timestamps
Supporting higher precision on our timestamps seems worthwhile, and
useful to logging implementations for getting more accurate numbers from
redfish LogService interfaces.
This commit updates the code to add millisecond and microsecond
precision to timestamps.
Tested: Unit tests pass, pretty good coverage here.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I0914908966702a6cf1bcb59f22761dc24c46b4c3
diff --git a/http/ut/utility_test.cpp b/http/ut/utility_test.cpp
index a1125b4..8bc122f 100644
--- a/http/ut/utility_test.cpp
+++ b/http/ut/utility_test.cpp
@@ -118,11 +118,24 @@
TEST(Utility, GetDateTimeUintMs)
{
+ EXPECT_EQ(getDateTimeUintMs(uint64_t{1638312095123}),
+ "2021-11-30T22:41:35.123+00:00");
// returns the maximum Redfish date
EXPECT_EQ(getDateTimeUintMs(std::numeric_limits<uint64_t>::max()),
- "9999-12-31T23:59:59+00:00");
+ "9999-12-31T23:59:59.999+00:00");
EXPECT_EQ(getDateTimeUintMs(std::numeric_limits<uint64_t>::min()),
- "1970-01-01T00:00:00+00:00");
+ "1970-01-01T00:00:00.000+00:00");
+}
+
+TEST(Utility, GetDateTimeUintUs)
+{
+ EXPECT_EQ(getDateTimeUintUs(uint64_t{1638312095123456}),
+ "2021-11-30T22:41:35.123456+00:00");
+ // returns the maximum Redfish date
+ EXPECT_EQ(getDateTimeUintUs(std::numeric_limits<uint64_t>::max()),
+ "9999-12-31T23:59:59.999999+00:00");
+ EXPECT_EQ(getDateTimeUintUs(std::numeric_limits<uint64_t>::min()),
+ "1970-01-01T00:00:00.000000+00:00");
}
TEST(Utility, UrlFromPieces)