time on linx fix
parent
89bde7c6e8
commit
e9a11a9a7e
|
@ -318,8 +318,14 @@ namespace blt::logging {
|
||||||
delete(output);
|
delete(output);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define BLT_NOW() auto t = std::time(nullptr); tm now; localtime_s(&now, &t); //auto now = std::localtime(&t)
|
#ifdef WIN32
|
||||||
|
#define BLT_NOW() auto t = std::time(nullptr); tm now{}; localtime_s(&now, &t)
|
||||||
|
#else
|
||||||
|
#define BLT_NOW() auto t = std::time(nullptr); auto now_ptr = std::localtime(&t); auto& now = *now_ptr
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//#define BLT_NOW() auto t = std::time(nullptr); tm now; localtime_s(&now, &t); //auto now = std::localtime(&t)
|
||||||
#define BLT_ISO_YEAR(S) auto S = std::to_string(now.tm_year + 1900); \
|
#define BLT_ISO_YEAR(S) auto S = std::to_string(now.tm_year + 1900); \
|
||||||
S += '-'; \
|
S += '-'; \
|
||||||
S += ensureHasDigits(now.tm_mon+1, 2); \
|
S += ensureHasDigits(now.tm_mon+1, 2); \
|
||||||
|
|
|
@ -13,6 +13,11 @@
|
||||||
|
|
||||||
namespace blt::system
|
namespace blt::system
|
||||||
{
|
{
|
||||||
|
#ifdef WIN32
|
||||||
|
#define TIME_FUNC tm now{}; localtime_s(&now, &t)
|
||||||
|
#else
|
||||||
|
#define TIME_FUNC auto now_ptr = std::localtime(&t); auto& now = *now_ptr
|
||||||
|
#endif
|
||||||
|
|
||||||
static inline std::string ensureHasDigits(int current, int digits)
|
static inline std::string ensureHasDigits(int current, int digits)
|
||||||
{
|
{
|
||||||
|
@ -86,8 +91,7 @@ namespace blt::system
|
||||||
static inline std::string getTimeString()
|
static inline std::string getTimeString()
|
||||||
{
|
{
|
||||||
auto t = std::time(nullptr);
|
auto t = std::time(nullptr);
|
||||||
tm now{};
|
TIME_FUNC;
|
||||||
localtime_s(&now, &t);
|
|
||||||
//auto now = std::localtime(&t);
|
//auto now = std::localtime(&t);
|
||||||
std::stringstream timeString;
|
std::stringstream timeString;
|
||||||
timeString << (1900 + now.tm_year);
|
timeString << (1900 + now.tm_year);
|
||||||
|
@ -112,8 +116,7 @@ namespace blt::system
|
||||||
static inline std::string getTimeStringLog()
|
static inline std::string getTimeStringLog()
|
||||||
{
|
{
|
||||||
auto t = std::time(nullptr);
|
auto t = std::time(nullptr);
|
||||||
tm now{};
|
TIME_FUNC;
|
||||||
localtime_s(&now, &t);
|
|
||||||
//auto now = std::localtime(&t);
|
//auto now = std::localtime(&t);
|
||||||
std::string timeString = "[";
|
std::string timeString = "[";
|
||||||
timeString += ensureHasDigits(now.tm_hour, 2);
|
timeString += ensureHasDigits(now.tm_hour, 2);
|
||||||
|
@ -131,8 +134,7 @@ namespace blt::system
|
||||||
static inline std::string getTimeStringFS()
|
static inline std::string getTimeStringFS()
|
||||||
{
|
{
|
||||||
auto t = std::time(nullptr);
|
auto t = std::time(nullptr);
|
||||||
tm now{};
|
TIME_FUNC;
|
||||||
localtime_s(&now, &t);
|
|
||||||
//auto now = std::localtime(&t);
|
//auto now = std::localtime(&t);
|
||||||
std::stringstream timeString;
|
std::stringstream timeString;
|
||||||
timeString << (1900 + now.tm_year);
|
timeString << (1900 + now.tm_year);
|
||||||
|
|
Loading…
Reference in New Issue