Fix compiling with old GCC

This commit is contained in:
Gioacchino Mazzurco 2018-07-22 22:47:30 +02:00
parent d9aa37219c
commit 51c25219bb
No known key found for this signature in database
GPG Key ID: A1FBCA3872E87051

View File

@ -243,7 +243,6 @@
#include <math.h>
#include <sstream>
#include <typeinfo>
#include <iomanip>
#include "rsgxsnetservice.h"
#include "gxssecurity.h"
@ -262,6 +261,13 @@
# include "deep_search/deep_search.h"
#endif
#include "util/cxx11retrocompat.h"
#if defined(GCC_VERSION) && GCC_VERSION > 50100
# include <iomanip>
#else
# include <cstdio>
#endif
/***
* Use the following defines to debug:
NXS_NET_DEBUG_0 shows group update high level information
@ -5303,9 +5309,15 @@ bool RsGxsNetService::search( const std::string& substring,
s.mSignFlags = std::stoul(rit->second);
if((rit = uQ.find("publishDate")) != uQ.end())
{
std::tm tm; memset(&tm, 0, sizeof(tm));
#if defined(GCC_VERSION) && GCC_VERSION > 50100
std::istringstream ss(rit->second);
std::tm tm;
ss >> std::get_time(&tm, "%Y%m%d");
#else // defined(GCC_VERSION) && GCC_VERSION > 50100
sscanf( rit->second.c_str(),
"%4d%2d%2d", &tm.tm_year, &tm.tm_mon, &tm.tm_mday );
#endif // defined(GCC_VERSION) && GCC_VERSION > 50100
s.mPublishTs = mktime(&tm);
}
if((rit = uQ.find("authorId")) != uQ.end())