Move time utils to be in one place

We've accumulated several time utility functions in the http classes.
Time isn't a core HTTP primitive, so http is not where those functions
below.

This commit moves all the time functions from the crow::utility
namespace into the redfish::time_utils namespace, as well as moves the
unit tests.

No code changes where made to the individual functions, with the
exception of changing the namespace on the unit tests.

Tested: Unit tests pass.

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I8493375f60aea31899c84ae703e0f71a17dbdb73
diff --git a/redfish-core/lib/certificate_service.hpp b/redfish-core/lib/certificate_service.hpp
index fc347dc..471b45a 100644
--- a/redfish-core/lib/certificate_service.hpp
+++ b/redfish-core/lib/certificate_service.hpp
@@ -690,7 +690,7 @@
                 if (value != nullptr)
                 {
                     asyncResp->res.jsonValue["ValidNotAfter"] =
-                        crow::utility::getDateTimeUint(*value);
+                        redfish::time_utils::getDateTimeUint(*value);
                 }
             }
             else if (property.first == "ValidNotBefore")
@@ -699,7 +699,7 @@
                 if (value != nullptr)
                 {
                     asyncResp->res.jsonValue["ValidNotBefore"] =
-                        crow::utility::getDateTimeUint(*value);
+                        redfish::time_utils::getDateTimeUint(*value);
                 }
             }
         }
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index e806bfa..32afd36 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -38,6 +38,7 @@
 #include <error_messages.hpp>
 #include <query.hpp>
 #include <registries/privilege_registry.hpp>
+#include <utils/time_utils.hpp>
 
 #include <charconv>
 #include <filesystem>
@@ -178,7 +179,8 @@
                          << strerror(-ret);
         return false;
     }
-    entryTimestamp = crow::utility::getDateTimeUint(timestamp / 1000 / 1000);
+    entryTimestamp =
+        redfish::time_utils::getDateTimeUint(timestamp / 1000 / 1000);
     return true;
 }
 
@@ -495,7 +497,8 @@
             thisEntry["@odata.id"] = entriesPath + entryID;
             thisEntry["Id"] = entryID;
             thisEntry["EntryType"] = "Event";
-            thisEntry["Created"] = crow::utility::getDateTimeUint(timestamp);
+            thisEntry["Created"] =
+                redfish::time_utils::getDateTimeUint(timestamp);
             thisEntry["Name"] = dumpType + " Dump Entry";
 
             if (dumpType == "BMC")
@@ -580,7 +583,7 @@
             asyncResp->res.jsonValue["Id"] = entryID;
             asyncResp->res.jsonValue["EntryType"] = "Event";
             asyncResp->res.jsonValue["Created"] =
-                crow::utility::getDateTimeUint(timestamp);
+                redfish::time_utils::getDateTimeUint(timestamp);
             asyncResp->res.jsonValue["Name"] = dumpType + " Dump Entry";
 
             if (dumpType == "BMC")
@@ -990,7 +993,7 @@
         asyncResp->res.jsonValue["OverWritePolicy"] = "WrapsWhenFull";
 
         std::pair<std::string, std::string> redfishDateTimeOffset =
-            crow::utility::getDateTimeOffsetNow();
+            redfish::time_utils::getDateTimeOffsetNow();
 
         asyncResp->res.jsonValue["DateTime"] = redfishDateTimeOffset.first;
         asyncResp->res.jsonValue["DateTimeLocalOffset"] =
@@ -1442,9 +1445,9 @@
                 thisEntry["Severity"] =
                     translateSeverityDbusToRedfish(*severity);
                 thisEntry["Created"] =
-                    crow::utility::getDateTimeUintMs(*timestamp);
+                    redfish::time_utils::getDateTimeUintMs(*timestamp);
                 thisEntry["Modified"] =
-                    crow::utility::getDateTimeUintMs(*updateTimestamp);
+                    redfish::time_utils::getDateTimeUintMs(*updateTimestamp);
                 if (filePath != nullptr)
                 {
                     thisEntry["AdditionalDataURI"] =
@@ -1565,9 +1568,9 @@
             asyncResp->res.jsonValue["Severity"] =
                 translateSeverityDbusToRedfish(*severity);
             asyncResp->res.jsonValue["Created"] =
-                crow::utility::getDateTimeUintMs(*timestamp);
+                redfish::time_utils::getDateTimeUintMs(*timestamp);
             asyncResp->res.jsonValue["Modified"] =
-                crow::utility::getDateTimeUintMs(*updateTimestamp);
+                redfish::time_utils::getDateTimeUintMs(*updateTimestamp);
             if (filePath != nullptr)
             {
                 asyncResp->res.jsonValue["AdditionalDataURI"] =
@@ -2106,7 +2109,7 @@
         asyncResp->res.jsonValue["OverWritePolicy"] = "WrapsWhenFull";
 
         std::pair<std::string, std::string> redfishDateTimeOffset =
-            crow::utility::getDateTimeOffsetNow();
+            redfish::time_utils::getDateTimeOffsetNow();
         asyncResp->res.jsonValue["DateTime"] = redfishDateTimeOffset.first;
         asyncResp->res.jsonValue["DateTimeLocalOffset"] =
             redfishDateTimeOffset.second;
@@ -2378,7 +2381,7 @@
     asyncResp->res.jsonValue["OverWritePolicy"] = std::move(overWritePolicy);
 
     std::pair<std::string, std::string> redfishDateTimeOffset =
-        crow::utility::getDateTimeOffsetNow();
+        redfish::time_utils::getDateTimeOffsetNow();
     asyncResp->res.jsonValue["DateTime"] = redfishDateTimeOffset.first;
     asyncResp->res.jsonValue["DateTimeLocalOffset"] =
         redfishDateTimeOffset.second;
@@ -2578,7 +2581,7 @@
         asyncResp->res.jsonValue["OverWritePolicy"] = "WrapsWhenFull";
 
         std::pair<std::string, std::string> redfishDateTimeOffset =
-            crow::utility::getDateTimeOffsetNow();
+            redfish::time_utils::getDateTimeOffsetNow();
         asyncResp->res.jsonValue["DateTime"] = redfishDateTimeOffset.first;
         asyncResp->res.jsonValue["DateTimeLocalOffset"] =
             redfishDateTimeOffset.second;
@@ -2712,7 +2715,7 @@
         asyncResp->res.jsonValue["MaxNumberOfRecords"] = 3;
 
         std::pair<std::string, std::string> redfishDateTimeOffset =
-            crow::utility::getDateTimeOffsetNow();
+            redfish::time_utils::getDateTimeOffsetNow();
         asyncResp->res.jsonValue["DateTime"] = redfishDateTimeOffset.first;
         asyncResp->res.jsonValue["DateTimeLocalOffset"] =
             redfishDateTimeOffset.second;
@@ -3195,7 +3198,7 @@
             "/redfish/v1/Systems/system/LogServices/PostCodes/Entries";
 
         std::pair<std::string, std::string> redfishDateTimeOffset =
-            crow::utility::getDateTimeOffsetNow();
+            redfish::time_utils::getDateTimeOffsetNow();
         asyncResp->res.jsonValue["DateTime"] = redfishDateTimeOffset.first;
         asyncResp->res.jsonValue["DateTimeLocalOffset"] =
             redfishDateTimeOffset.second;
@@ -3302,7 +3305,7 @@
         // Get the Created time from the timestamp
         std::string entryTimeStr;
         entryTimeStr =
-            crow::utility::getDateTimeUint(usecSinceEpoch / 1000 / 1000);
+            redfish::time_utils::getDateTimeUint(usecSinceEpoch / 1000 / 1000);
 
         // assemble messageArgs: BootIndex, TimeOffset(100us), PostCode(hex)
         std::ostringstream hexCode;
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index a98ff22..b8fe156 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -24,6 +24,7 @@
 #include "utils/dbus_utils.hpp"
 #include "utils/sw_utils.hpp"
 #include "utils/systemd_utils.hpp"
+#include "utils/time_utils.hpp"
 
 #include <boost/date_time.hpp>
 #include <sdbusplus/asio/property.hpp>
@@ -1750,7 +1751,7 @@
 
         // Convert to ISO 8601 standard
         aResp->res.jsonValue["LastResetTime"] =
-            crow::utility::getDateTimeUint(lastResetTimeStamp);
+            redfish::time_utils::getDateTimeUint(lastResetTimeStamp);
         });
 }
 
@@ -1984,7 +1985,7 @@
         resetToDefaults["ResetType@Redfish.AllowableValues"] = {"ResetAll"};
 
         std::pair<std::string, std::string> redfishDateTimeOffset =
-            crow::utility::getDateTimeOffsetNow();
+            redfish::time_utils::getDateTimeOffsetNow();
 
         asyncResp->res.jsonValue["DateTime"] = redfishDateTimeOffset.first;
         asyncResp->res.jsonValue["DateTimeLocalOffset"] =
diff --git a/redfish-core/lib/metric_report.hpp b/redfish-core/lib/metric_report.hpp
index b93483c..18830f1 100644
--- a/redfish-core/lib/metric_report.hpp
+++ b/redfish-core/lib/metric_report.hpp
@@ -2,6 +2,7 @@
 
 #include "utils/collection.hpp"
 #include "utils/telemetry_utils.hpp"
+#include "utils/time_utils.hpp"
 
 #include <app.hpp>
 #include <dbus_utility.hpp>
@@ -32,7 +33,7 @@
             {"MetricId", id},
             {"MetricProperty", metadata},
             {"MetricValue", std::to_string(sensorValue)},
-            {"Timestamp", crow::utility::getDateTimeUintMs(timestamp)},
+            {"Timestamp", redfish::time_utils::getDateTimeUintMs(timestamp)},
         });
     }
 
@@ -55,7 +56,7 @@
             .string();
 
     const auto& [timestamp, readings] = timestampReadings;
-    json["Timestamp"] = crow::utility::getDateTimeUintMs(timestamp);
+    json["Timestamp"] = redfish::time_utils::getDateTimeUintMs(timestamp);
     json["MetricValues"] = toMetricValues(readings);
     return true;
 }
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index dd58e1b..0c2c53c 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -21,6 +21,7 @@
 #include "pcie.hpp"
 #include "query.hpp"
 #include "redfish_util.hpp"
+#include "utils/time_utils.hpp"
 
 #include <app.hpp>
 #include <boost/container/flat_map.hpp>
@@ -1079,7 +1080,7 @@
 
         // Convert to ISO 8601 standard
         aResp->res.jsonValue["LastResetTime"] =
-            crow::utility::getDateTimeUint(lastResetTimeStamp);
+            redfish::time_utils::getDateTimeUint(lastResetTimeStamp);
         });
 }
 
diff --git a/redfish-core/lib/task.hpp b/redfish-core/lib/task.hpp
index 7d96e42..be48a5b 100644
--- a/redfish-core/lib/task.hpp
+++ b/redfish-core/lib/task.hpp
@@ -395,11 +395,11 @@
         asyncResp->res.jsonValue["Name"] = "Task " + strParam;
         asyncResp->res.jsonValue["TaskState"] = ptr->state;
         asyncResp->res.jsonValue["StartTime"] =
-            crow::utility::getDateTimeStdtime(ptr->startTime);
+            redfish::time_utils::getDateTimeStdtime(ptr->startTime);
         if (ptr->endTime)
         {
             asyncResp->res.jsonValue["EndTime"] =
-                crow::utility::getDateTimeStdtime(*(ptr->endTime));
+                redfish::time_utils::getDateTimeStdtime(*(ptr->endTime));
         }
         asyncResp->res.jsonValue["TaskStatus"] = ptr->status;
         asyncResp->res.jsonValue["Messages"] = ptr->messages;
@@ -473,7 +473,7 @@
         asyncResp->res.jsonValue["Name"] = "Task Service";
         asyncResp->res.jsonValue["Id"] = "TaskService";
         asyncResp->res.jsonValue["DateTime"] =
-            crow::utility::getDateTimeOffsetNow().first;
+            redfish::time_utils::getDateTimeOffsetNow().first;
         asyncResp->res.jsonValue["CompletedTaskOverWritePolicy"] = "Oldest";
 
         asyncResp->res.jsonValue["LifeCycleEventOnTaskStateChange"] = true;