diff options
author | louiz’ <louiz@louiz.org> | 2016-11-07 20:26:28 +0100 |
---|---|---|
committer | louiz’ <louiz@louiz.org> | 2016-11-07 20:26:28 +0100 |
commit | a52baa52e25c9767d1be95a10b2a56334aaeb471 (patch) | |
tree | 27744e76699c8bc2630e2289233d744f642fd114 /src/xmpp | |
parent | 597cfce4b88f9318ed8b580e8b26df9be8fc637a (diff) | |
download | biboumi-a52baa52e25c9767d1be95a10b2a56334aaeb471.tar.gz biboumi-a52baa52e25c9767d1be95a10b2a56334aaeb471.tar.bz2 biboumi-a52baa52e25c9767d1be95a10b2a56334aaeb471.tar.xz biboumi-a52baa52e25c9767d1be95a10b2a56334aaeb471.zip |
Workaround for debian and other old OS that do not have std::put_time
Diffstat (limited to 'src/xmpp')
-rw-r--r-- | src/xmpp/biboumi_adhoc_commands.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/xmpp/biboumi_adhoc_commands.cpp b/src/xmpp/biboumi_adhoc_commands.cpp index 1349a66..003b901 100644 --- a/src/xmpp/biboumi_adhoc_commands.cpp +++ b/src/xmpp/biboumi_adhoc_commands.cpp @@ -15,6 +15,10 @@ #include <database/database.hpp> #endif +#ifndef HAS_PUT_TIME +#include <ctime> +#endif + using namespace std::string_literals; void DisconnectUserStep1(XmppComponent& xmpp_component, AdhocSession&, XmlNode& command_node) @@ -766,7 +770,15 @@ 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); +#ifdef HAS_PUT_TIME ss << " since " << std::put_time(std::localtime(&now_c), "%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)); + if (res > 0) + ss << " since " << buf; +#endif ss << " (" << std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() - irc->connection_date).count() << " seconds ago)."; for (const auto& it: bridge->resources_in_chan) |