aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Woosley <[email protected]>2020-03-18 15:23:25 -0700
committerfanquake <[email protected]>2020-04-02 12:31:54 +0800
commita46484c8b3715725f5dc0b8ad1bf921880ed9af1 (patch)
treec73218fdc972628f7fbba821de162267bed6af86 /src
parentMerge #18492: qt: Translations update pre-branch (diff)
downloaddiscoin-a46484c8b3715725f5dc0b8ad1bf921880ed9af1.tar.xz
discoin-a46484c8b3715725f5dc0b8ad1bf921880ed9af1.zip
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 <[email protected]>
Diffstat (limited to 'src')
-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 14937b985..0938ff36a 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 {};
}