2022-07-24 00:55:18 +02:00
|
|
|
#include <renderd7/Time.hpp>
|
2022-07-29 13:19:31 +02:00
|
|
|
#include <memory>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <time.h>
|
2022-07-31 01:23:39 +02:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <fstream>
|
|
|
|
#include <string.h>
|
|
|
|
#include <string>
|
|
|
|
|
2022-07-29 13:19:31 +02:00
|
|
|
|
|
|
|
std::string RenderD7::FormatString(std::string fmt_str, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
char* fp = NULL;
|
|
|
|
va_start(ap, fmt_str);
|
|
|
|
vasprintf(&fp, fmt_str.c_str(), ap);
|
|
|
|
va_end(ap);
|
|
|
|
std::unique_ptr<char, decltype(free)*> formatted(fp, free);
|
|
|
|
return std::string(formatted.get());
|
|
|
|
}
|
2021-12-01 20:38:44 +01:00
|
|
|
|
2022-07-29 13:19:31 +02:00
|
|
|
std::string RenderD7::GetTimeStr(void)
|
|
|
|
{
|
2022-07-31 01:23:39 +02:00
|
|
|
time_t unixTime;
|
|
|
|
struct tm timeStruct;
|
|
|
|
time(&unixTime);
|
|
|
|
localtime_r(&unixTime, &timeStruct);
|
|
|
|
return FormatString("%04i-%02i-%02i_%02i-%02i-%02i", timeStruct.tm_year + 1900, timeStruct.tm_mon + 1, timeStruct.tm_mday,
|
|
|
|
timeStruct.tm_hour, timeStruct.tm_min, timeStruct.tm_sec);
|
2021-12-01 20:38:44 +01:00
|
|
|
}
|