summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2019-09-23 22:07:57 +0200
committerlouiz’ <louiz@louiz.org>2019-09-23 22:07:57 +0200
commit6ab064d04d76d057401aeb598fe300deb48b4965 (patch)
tree65b397f490e6da01a42c3f327d2ec43e8fc3534d /src/utils
parent89bb886a1b4db9b7604680db8de17d08d3c26e89 (diff)
downloadbiboumi-6ab064d04d76d057401aeb598fe300deb48b4965.tar.gz
biboumi-6ab064d04d76d057401aeb598fe300deb48b4965.tar.bz2
biboumi-6ab064d04d76d057401aeb598fe300deb48b4965.tar.xz
biboumi-6ab064d04d76d057401aeb598fe300deb48b4965.zip
USe safer functions, gmtime_r and localtime_r
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/time.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/utils/time.cpp b/src/utils/time.cpp
index 71306fd..2812c72 100644
--- a/src/utils/time.cpp
+++ b/src/utils/time.cpp
@@ -1,5 +1,5 @@
#include <utils/time.hpp>
-#include <ctime>
+#include <time.h>
#include <sstream>
#include <iomanip>
@@ -14,7 +14,8 @@ std::string to_string(const std::chrono::system_clock::time_point::rep& time)
constexpr std::size_t stamp_size = 21;
const std::time_t timestamp = static_cast<std::time_t>(time);
char date_buf[stamp_size];
- if (std::strftime(date_buf, stamp_size, "%FT%TZ", std::gmtime(&timestamp)) != stamp_size - 1)
+ struct tm tm;
+ if (std::strftime(date_buf, stamp_size, "%FT%TZ", gmtime_r(&timestamp, &tm)) != stamp_size - 1)
return "";
return {std::begin(date_buf), std::end(date_buf) - 1};
}