diff options
author | louiz’ <louiz@louiz.org> | 2019-09-23 22:07:57 +0200 |
---|---|---|
committer | louiz’ <louiz@louiz.org> | 2019-09-23 22:07:57 +0200 |
commit | 6ab064d04d76d057401aeb598fe300deb48b4965 (patch) | |
tree | 65b397f490e6da01a42c3f327d2ec43e8fc3534d /src/xmpp | |
parent | 89bb886a1b4db9b7604680db8de17d08d3c26e89 (diff) | |
download | biboumi-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/xmpp')
-rw-r--r-- | src/xmpp/biboumi_adhoc_commands.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
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 |