From 5c0fd2bacb4f1b90e5a50b891c07c5cabb946773 Mon Sep 17 00:00:00 2001 From: yashrajsapra Date: Mon, 5 Aug 2024 22:08:32 +0530 Subject: [PATCH] Added Defination of getCurrentTimestamp --- base/src/APHealthObject.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/base/src/APHealthObject.cpp b/base/src/APHealthObject.cpp index 707f81fc6..d5fbf2d23 100644 --- a/base/src/APHealthObject.cpp +++ b/base/src/APHealthObject.cpp @@ -1,6 +1,7 @@ #include "APHealthObject.h" #include "Logger.h" #include +#include APHealthObject::APHealthObject(const std::string &modId) : mModuleId(modId) { @@ -9,9 +10,12 @@ APHealthObject::APHealthObject(const std::string &modId) : mModuleId(modId) std::string APHealthObject::getCurrentTimestamp() const { - // Implement a function to get the current timestamp - // For now, returning a placeholder - return "2024-07-12 10:00:00"; + auto now = std::chrono::system_clock::now(); + std::time_t now_time = std::chrono::system_clock::to_time_t(now); + std::tm tm = *std::localtime(&now_time); + std::stringstream ss; + ss << std::put_time(&tm, "%Y-%m-%d %H:%M:%S"); + return ss.str(); } std::string APHealthObject::getModuleId() const { return mModuleId; }