aboutsummaryrefslogtreecommitdiff
path: root/src/utiltime.cpp
diff options
context:
space:
mode:
authorAaron Clauson <aaron@sipsorcery.com>2018-04-20 08:41:15 +1000
committerAaron Clauson <aaron@sipsorcery.com>2018-04-20 08:41:15 +1000
commitabd58a2fcae767e9074c49b64e9c89e5168d7005 (patch)
tree798fa5da20f0556cea2827873223f6ce889d8080 /src/utiltime.cpp
parent0a8b7b4b33c9d78574627fc606267e2d8955cd1c (diff)
Fix for utiltime to compile with msvc.
Diffstat (limited to 'src/utiltime.cpp')
-rw-r--r--src/utiltime.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/utiltime.cpp b/src/utiltime.cpp
index 34800c7b6d..e60996efe1 100644
--- a/src/utiltime.cpp
+++ b/src/utiltime.cpp
@@ -79,20 +79,32 @@ void MilliSleep(int64_t n)
std::string FormatISO8601DateTime(int64_t nTime) {
struct tm ts;
time_t time_val = nTime;
+#ifdef _MSC_VER
+ gmtime_s(&ts, &time_val);
+#else
gmtime_r(&time_val, &ts);
+#endif
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);
}
std::string FormatISO8601Date(int64_t nTime) {
struct tm ts;
time_t time_val = nTime;
+#ifdef _MSC_VER
+ gmtime_s(&ts, &time_val);
+#else
gmtime_r(&time_val, &ts);
+#endif
return strprintf("%04i-%02i-%02i", ts.tm_year + 1900, ts.tm_mon + 1, ts.tm_mday);
}
std::string FormatISO8601Time(int64_t nTime) {
struct tm ts;
time_t time_val = nTime;
+#ifdef _MSC_VER
+ gmtime_s(&ts, &time_val);
+#else
gmtime_r(&time_val, &ts);
+#endif
return strprintf("%02i:%02i:%02iZ", ts.tm_hour, ts.tm_min, ts.tm_sec);
}