diff options
author | Ben Woosley <ben.woosley@gmail.com> | 2020-03-18 15:23:25 -0700 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2020-04-02 12:31:54 +0800 |
commit | a46484c8b3715725f5dc0b8ad1bf921880ed9af1 (patch) | |
tree | c73218fdc972628f7fbba821de162267bed6af86 /src/util/time.cpp | |
parent | 41fa2926d86a57c9623d34debef20746ee2f454a (diff) |
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>
Diffstat (limited to 'src/util/time.cpp')
-rw-r--r-- | src/util/time.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
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 {}; } |