Skip to content

Commit 826acc9

Browse files
committed
Merge #13031: Fix for utiltime to compile with msvc.
abd58a2 Fix for utiltime to compile with msvc. (Aaron Clauson) Pull request description: This PR allows utiltime.cpp to compile with msvc after the changes introduced in #12973. Tree-SHA512: 7233b1c23400bf19aef2fcb6168009ef58b9e7f8e49c46d8cf9d04394091f370e39496d24ca00b294c4164bcfc04514e329bf6bb05169406c34ce7cd8c382565
2 parents eac067a + abd58a2 commit 826acc9

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/utiltime.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,32 @@ void MilliSleep(int64_t n)
7979
std::string FormatISO8601DateTime(int64_t nTime) {
8080
struct tm ts;
8181
time_t time_val = nTime;
82+
#ifdef _MSC_VER
83+
gmtime_s(&ts, &time_val);
84+
#else
8285
gmtime_r(&time_val, &ts);
86+
#endif
8387
return strprintf("%04i-%02i-%02iT%02i:%02i:%02iZ", ts.tm_year + 1900, ts.tm_mon + 1, ts.tm_mday, ts.tm_hour, ts.tm_min, ts.tm_sec);
8488
}
8589

8690
std::string FormatISO8601Date(int64_t nTime) {
8791
struct tm ts;
8892
time_t time_val = nTime;
93+
#ifdef _MSC_VER
94+
gmtime_s(&ts, &time_val);
95+
#else
8996
gmtime_r(&time_val, &ts);
97+
#endif
9098
return strprintf("%04i-%02i-%02i", ts.tm_year + 1900, ts.tm_mon + 1, ts.tm_mday);
9199
}
92100

93101
std::string FormatISO8601Time(int64_t nTime) {
94102
struct tm ts;
95103
time_t time_val = nTime;
104+
#ifdef _MSC_VER
105+
gmtime_s(&ts, &time_val);
106+
#else
96107
gmtime_r(&time_val, &ts);
108+
#endif
97109
return strprintf("%02i:%02i:%02iZ", ts.tm_hour, ts.tm_min, ts.tm_sec);
98110
}

0 commit comments

Comments
 (0)