Skip to content

Commit

Permalink
Added Defination of getCurrentTimestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
yashrajsapra committed Aug 5, 2024
1 parent 683c4af commit 5c0fd2b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions base/src/APHealthObject.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "APHealthObject.h"
#include "Logger.h"
#include <ctime>
#include <chrono>

APHealthObject::APHealthObject(const std::string &modId) : mModuleId(modId)
{
Expand All @@ -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; }
Expand Down

0 comments on commit 5c0fd2b

Please sign in to comment.