From 0e6f29e3f6d1dc2ed7eb06a4c1e31814cefecdbb Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Tue, 10 Dec 2019 07:41:04 +0300 Subject: server: use safe & portable Boost.DateTime functions --- server/common/log.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'server/common') diff --git a/server/common/log.hpp b/server/common/log.hpp index ca0fafd..48dd0f6 100644 --- a/server/common/log.hpp +++ b/server/common/log.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include @@ -20,9 +21,10 @@ namespace details { inline std::thread::id get_tid() { return std::this_thread::get_id(); } inline std::string get_timestamp() { - const auto tt = std::time(nullptr); + const auto now = boost::posix_time::second_clock::universal_time(); + const auto tm = boost::posix_time::to_tm(now); std::ostringstream oss; - oss << std::put_time(std::gmtime(&tt), "%Y-%m-%d %H:%M:%S"); + oss << std::put_time(&tm, "%Y-%m-%d %H:%M:%S"); return oss.str(); } -- cgit v1.2.3