mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-12-24 14:17:46 +00:00
blockchain_stats: don't use gmtime_r on Windows
In some cases, it doesn't like it (I don't know the details). Factor into a new epee function
This commit is contained in:
parent
84dd674cd0
commit
96e6b43970
4 changed files with 13 additions and 12 deletions
|
@ -122,6 +122,15 @@ namespace misc_utils
|
||||||
return boost::lexical_cast<std::string>(GetCurrentThreadId());
|
return boost::lexical_cast<std::string>(GetCurrentThreadId());
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
return boost::lexical_cast<std::string>(pthread_self());
|
return boost::lexical_cast<std::string>(pthread_self());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool get_gmt_time(time_t t, struct tm &tm)
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
return gmtime_s(&tm, &t);
|
||||||
|
#else
|
||||||
|
return gmtime_r(&t, &tm);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
#include "string_tools.h"
|
#include "string_tools.h"
|
||||||
|
#include "misc_os_dependent.h"
|
||||||
#include "misc_log_ex.h"
|
#include "misc_log_ex.h"
|
||||||
|
|
||||||
#undef MONERO_DEFAULT_LOG_CATEGORY
|
#undef MONERO_DEFAULT_LOG_CATEGORY
|
||||||
|
@ -58,12 +59,7 @@ static std::string generate_log_filename(const char *base)
|
||||||
char tmp[200];
|
char tmp[200];
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
if
|
if (!epee::misc_utils::get_gmt_time(now, tm))
|
||||||
#ifdef WIN32
|
|
||||||
(!gmtime_s(&tm, &now))
|
|
||||||
#else
|
|
||||||
(!gmtime_r(&now, &tm))
|
|
||||||
#endif
|
|
||||||
snprintf(tmp, sizeof(tmp), "part-%u", ++fallback_counter);
|
snprintf(tmp, sizeof(tmp), "part-%u", ++fallback_counter);
|
||||||
else
|
else
|
||||||
strftime(tmp, sizeof(tmp), "%Y-%m-%d-%H-%M-%S", &tm);
|
strftime(tmp, sizeof(tmp), "%Y-%m-%d-%H-%M-%S", &tm);
|
||||||
|
|
|
@ -234,7 +234,7 @@ plot 'stats.csv' index "DATA" using (timecolumn(1,"%Y-%m-%d")):4 with lines, ''
|
||||||
}
|
}
|
||||||
time_t tt = blk.timestamp;
|
time_t tt = blk.timestamp;
|
||||||
char timebuf[64];
|
char timebuf[64];
|
||||||
gmtime_r(&tt, &currtm);
|
epee::misc_utils::get_gmt_time(tt, currtm);
|
||||||
if (!prevtm.tm_year)
|
if (!prevtm.tm_year)
|
||||||
prevtm = currtm;
|
prevtm = currtm;
|
||||||
// catch change of day
|
// catch change of day
|
||||||
|
|
|
@ -6727,11 +6727,7 @@ static std::string get_human_readable_timestamp(uint64_t ts)
|
||||||
return "<unknown>";
|
return "<unknown>";
|
||||||
time_t tt = ts;
|
time_t tt = ts;
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
#ifdef WIN32
|
epee::misc_utils::get_gmt_time(tt, tm);
|
||||||
gmtime_s(&tm, &tt);
|
|
||||||
#else
|
|
||||||
gmtime_r(&tt, &tm);
|
|
||||||
#endif
|
|
||||||
uint64_t now = time(NULL);
|
uint64_t now = time(NULL);
|
||||||
uint64_t diff = ts > now ? ts - now : now - ts;
|
uint64_t diff = ts > now ? ts - now : now - ts;
|
||||||
strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", &tm);
|
strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", &tm);
|
||||||
|
|
Loading…
Reference in a new issue