summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/utils/time.cpp5
-rw-r--r--src/xmpp/biboumi_adhoc_commands.cpp7
2 files changed, 7 insertions, 5 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};
}
diff --git a/src/xmpp/biboumi_adhoc_commands.cpp b/src/xmpp/biboumi_adhoc_commands.cpp
index 7c31f36..f17a016 100644
--- a/src/xmpp/biboumi_adhoc_commands.cpp
+++ b/src/xmpp/biboumi_adhoc_commands.cpp
@@ -25,7 +25,7 @@ static void set_desc(XmlSubNode& field, const char* text)
#endif
#ifndef HAS_PUT_TIME
-#include <ctime>
+# include <time.h>
#endif
using namespace std::string_literals;
@@ -884,12 +884,13 @@ void GetIrcConnectionInfoStep1(XmppComponent& component, AdhocSession& session,
if (irc->is_using_tls())
ss << " (using TLS)";
const std::time_t now_c = std::chrono::system_clock::to_time_t(irc->connection_date);
+ struct tm tm;
#ifdef HAS_PUT_TIME
- ss << " since " << std::put_time(std::localtime(&now_c), "%F %T");
+ ss << " since " << std::put_time(localtime_r(&now_c, &tm), "%F %T");
#else
constexpr std::size_t timestamp_size{10 + 1 + 8 + 1};
char buf[timestamp_size] = {};
- const auto res = std::strftime(buf, timestamp_size, "%F %T", std::localtime(&now_c));
+ const auto res = std::strftime(buf, timestamp_size, "%F %T", localtime(&now_c, &tm));
if (res > 0)
ss << " since " << buf;
#endif