From a46484c8b3715725f5dc0b8ad1bf921880ed9af1 Mon Sep 17 00:00:00 2001 From: Ben Woosley Date: Wed, 18 Mar 2020 15:23:25 -0700 Subject: 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 --- src/util/time.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/util') diff --git a/src/util/time.cpp b/src/util/time.cpp index 14937b985e..0938ff36a6 100644 --- a/src/util/time.cpp +++ b/src/util/time.cpp @@ -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 {}; } -- cgit v1.2.3