Populate timestamps with microsecond precision

xyz.openbmc_project.Time.EpochTime is defined as time elapsed since the
epoch in microseconds.

xyz.openbmc_project.Common.Progress.StartTime and
xyz.openbmc_project.Common.Progress.CompletedTime are similarly
defined as microseconds.

Change timestamps that are currently captured in seconds to
microseconds.

Tested:

Check xyz.openbmc_project.Time.EpochTime,
xyz.openbmc_project.Common.Progress.StartTime, and
xyz.openbmc_project.Common.Progress.CompletedTime timestamps of dump
entries.

Example:
busctl introspect xyz.openbmc_project.Dump.Manager /xyz/openbmc_project/dump/bmc/entry/1

Signed-off-by: Claire Weinan <cweinan@google.com>
Change-Id: I6ea220af07f06ad79de0b62b24ce6cd5ba5fd33d
diff --git a/dump-extensions/openpower-dumps/dump_manager_resource.cpp b/dump-extensions/openpower-dumps/dump_manager_resource.cpp
index e4cb346..a151961 100644
--- a/dump-extensions/openpower-dumps/dump_manager_resource.cpp
+++ b/dump-extensions/openpower-dumps/dump_manager_resource.cpp
@@ -26,7 +26,10 @@
 void Manager::notify(uint32_t dumpId, uint64_t size)
 {
     // Get the timestamp
-    std::time_t timeStamp = std::time(nullptr);
+    uint64_t timeStamp =
+        std::chrono::duration_cast<std::chrono::microseconds>(
+            std::chrono::system_clock::now().time_since_epoch())
+            .count();
 
     // If there is an entry with invalid id update that.
     // If there a completed one with same source id ignore it
@@ -128,7 +131,10 @@
     auto id = lastEntryId + 1;
     auto idString = std::to_string(id);
     auto objPath = std::filesystem::path(baseEntryPath) / idString;
-    std::time_t timeStamp = std::time(nullptr);
+    uint64_t timeStamp =
+        std::chrono::duration_cast<std::chrono::microseconds>(
+            std::chrono::system_clock::now().time_since_epoch())
+            .count();
 
     std::string vspString;
     auto iter = params.find(
diff --git a/dump-extensions/openpower-dumps/dump_manager_system.cpp b/dump-extensions/openpower-dumps/dump_manager_system.cpp
index e8e8953..7310dec 100644
--- a/dump-extensions/openpower-dumps/dump_manager_system.cpp
+++ b/dump-extensions/openpower-dumps/dump_manager_system.cpp
@@ -26,7 +26,10 @@
 {
 
     // Get the timestamp
-    std::time_t timeStamp = std::time(nullptr);
+    uint64_t timeStamp =
+        std::chrono::duration_cast<std::chrono::microseconds>(
+            std::chrono::system_clock::now().time_since_epoch())
+            .count();
 
     // System dump can get created due to a fault in server
     // or by request from user. A system dump by fault is
@@ -107,7 +110,10 @@
     auto id = lastEntryId + 1;
     auto idString = std::to_string(id);
     auto objPath = std::filesystem::path(baseEntryPath) / idString;
-    std::time_t timeStamp = std::time(nullptr);
+    uint64_t timeStamp =
+        std::chrono::duration_cast<std::chrono::microseconds>(
+            std::chrono::system_clock::now().time_since_epoch())
+            .count();
 
     try
     {