mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +01:00
build: Detect gmtime_* definitions via configure
This improves the portability of the codebase and fixes compilation with mingw-w64 7.0+. Co-authored-by: fanquake <fanquake@gmail.com>
This commit is contained in:
@@ -78,10 +78,10 @@ int64_t GetSystemTimeInSeconds()
|
||||
std::string FormatISO8601DateTime(int64_t nTime) {
|
||||
struct tm ts;
|
||||
time_t time_val = nTime;
|
||||
#ifdef _MSC_VER
|
||||
if (gmtime_s(&ts, &time_val) != 0) {
|
||||
#else
|
||||
#ifdef HAVE_GMTIME_R
|
||||
if (gmtime_r(&time_val, &ts) == nullptr) {
|
||||
#else
|
||||
if (gmtime_s(&ts, &time_val) != 0) {
|
||||
#endif
|
||||
return {};
|
||||
}
|
||||
@@ -91,10 +91,10 @@ std::string FormatISO8601DateTime(int64_t nTime) {
|
||||
std::string FormatISO8601Date(int64_t nTime) {
|
||||
struct tm ts;
|
||||
time_t time_val = nTime;
|
||||
#ifdef _MSC_VER
|
||||
if (gmtime_s(&ts, &time_val) != 0) {
|
||||
#else
|
||||
#ifdef HAVE_GMTIME_R
|
||||
if (gmtime_r(&time_val, &ts) == nullptr) {
|
||||
#else
|
||||
if (gmtime_s(&ts, &time_val) != 0) {
|
||||
#endif
|
||||
return {};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user