aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorBen Woosley <ben.woosley@gmail.com>2020-03-18 15:23:25 -0700
committerfanquake <fanquake@gmail.com>2020-04-02 12:31:54 +0800
commita46484c8b3715725f5dc0b8ad1bf921880ed9af1 (patch)
treec73218fdc972628f7fbba821de162267bed6af86 /src/util
parent41fa2926d86a57c9623d34debef20746ee2f454a (diff)
downloadbitcoin-a46484c8b3715725f5dc0b8ad1bf921880ed9af1.tar.xz
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')
-rw-r--r--src/util/time.cpp12
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 {};
}