~singpolyma/biboumi

a52baa52e25c9767d1be95a10b2a56334aaeb471 — louiz’ 7 years ago 597cfce
Workaround for debian and other old OS that do not have std::put_time
3 files changed, 21 insertions(+), 0 deletions(-)

M louloulibs/CMakeLists.txt
M louloulibs/louloulibs.h.cmake
M src/xmpp/biboumi_adhoc_commands.cpp
M louloulibs/CMakeLists.txt => louloulibs/CMakeLists.txt +8 -0
@@ 156,4 156,12 @@ check_cxx_source_compiles("

mark_as_advanced(HAS_GET_TIME)

check_cxx_source_compiles("
  #include <iomanip>
  int main()
  { std::put_time(nullptr, \"\"); }"
  HAS_PUT_TIME)

mark_as_advanced(HAS_PUT_TIME)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/louloulibs.h.cmake ${CMAKE_BINARY_DIR}/src/louloulibs.h)

M louloulibs/louloulibs.h.cmake => louloulibs/louloulibs.h.cmake +1 -0
@@ 8,3 8,4 @@
#cmakedefine SOFTWARE_VERSION "${SOFTWARE_VERSION}"
#cmakedefine PROJECT_NAME "${PROJECT_NAME}"
#cmakedefine HAS_GET_TIME
#cmakedefine HAS_PUT_TIME

M src/xmpp/biboumi_adhoc_commands.cpp => src/xmpp/biboumi_adhoc_commands.cpp +12 -0
@@ 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)