mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-31 09:33:47 +00:00
feat(Core/Common): add new helpers for time utility (#10207)
This commit is contained in:
@@ -24,8 +24,8 @@
|
||||
#include "LogOperation.h"
|
||||
#include "Logger.h"
|
||||
#include "StringConvert.h"
|
||||
#include "Timer.h"
|
||||
#include "Tokenize.h"
|
||||
#include "Util.h"
|
||||
#include <chrono>
|
||||
#include <sstream>
|
||||
|
||||
@@ -275,19 +275,7 @@ Logger const* Log::GetLoggerByType(std::string const& type) const
|
||||
|
||||
std::string Log::GetTimestampStr()
|
||||
{
|
||||
time_t tt = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
|
||||
|
||||
std::tm aTm;
|
||||
localtime_r(&tt, &aTm);
|
||||
|
||||
// YYYY year
|
||||
// MM month (2 digits 01-12)
|
||||
// DD day (2 digits 01-31)
|
||||
// HH hour (2 digits 00-23)
|
||||
// MM minutes (2 digits 00-59)
|
||||
// SS seconds (2 digits 00-59)
|
||||
return Acore::StringFormat("%04d-%02d-%02d_%02d-%02d-%02d",
|
||||
aTm.tm_year + 1900, aTm.tm_mon + 1, aTm.tm_mday, aTm.tm_hour, aTm.tm_min, aTm.tm_sec);
|
||||
return Acore::Time::TimeToTimestampStr(GetEpochTime(), "%Y-%m-%d_%H_%M_%S");
|
||||
}
|
||||
|
||||
bool Log::SetLogLevel(std::string const& name, int32 newLeveli, bool isLogger /* = true */)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#include "LogMessage.h"
|
||||
#include "StringFormat.h"
|
||||
#include "Util.h"
|
||||
#include "Timer.h"
|
||||
|
||||
LogMessage::LogMessage(LogLevel _level, std::string const& _type, std::string&& _text)
|
||||
: level(_level), type(_type), text(std::forward<std::string>(_text)), mtime(time(nullptr))
|
||||
@@ -31,9 +31,7 @@ LogMessage::LogMessage(LogLevel _level, std::string const& _type, std::string&&
|
||||
|
||||
std::string LogMessage::getTimeStr(time_t time)
|
||||
{
|
||||
tm aTm;
|
||||
localtime_r(&time, &aTm);
|
||||
return Acore::StringFormat("%04d-%02d-%02d_%02d:%02d:%02d", aTm.tm_year + 1900, aTm.tm_mon + 1, aTm.tm_mday, aTm.tm_hour, aTm.tm_min, aTm.tm_sec);
|
||||
return Acore::Time::TimeToTimestampStr(Seconds(time), "%Y-%m-%d %X");
|
||||
}
|
||||
|
||||
std::string LogMessage::getTimeStr() const
|
||||
|
||||
Reference in New Issue
Block a user