mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-27 13:23:29 +01:00
gmtime for Windows
gmtime_r is not available in Windows, use gmtime_s instead. Also change shorthand codes (also not working in Windows).
This commit is contained in:
parent
a645a3e5ff
commit
57dce8083a
@ -2968,13 +2968,17 @@ 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
|
||||||
|
gmtime_s(&tm, &tt);
|
||||||
|
#else
|
||||||
gmtime_r(&tt, &tm);
|
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;
|
||||||
if (diff > 24*3600)
|
if (diff > 24*3600)
|
||||||
strftime(buffer, sizeof(buffer), "%F", &tm);
|
strftime(buffer, sizeof(buffer), "%Y-%m-%d", &tm);
|
||||||
else
|
else
|
||||||
strftime(buffer, sizeof(buffer), "%r", &tm);
|
strftime(buffer, sizeof(buffer), "%I:%M:%S %p", &tm);
|
||||||
return std::string(buffer);
|
return std::string(buffer);
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user