diff options
author | Thiago Marcos P. Santos <thiago@mapbox.com> | 2016-08-06 01:34:20 +0300 |
---|---|---|
committer | Thiago Marcos P. Santos <thiago@mapbox.com> | 2017-01-24 11:36:59 +0200 |
commit | 5ec6a54fa59c789c034b36c09fca8dfb194f06a2 (patch) | |
tree | 969c2eba91578d8c4df7c336f92a7c06b891cc62 | |
parent | 23c069d2295fe71c3cce028cec25dbc7b5d4d67d (diff) | |
download | qtlocation-mapboxgl-5ec6a54fa59c789c034b36c09fca8dfb194f06a2.tar.gz |
[core] Use gmtime_s on Windows
gmtime_r is POSIX
-rw-r--r-- | src/mbgl/util/chrono.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/mbgl/util/chrono.cpp b/src/mbgl/util/chrono.cpp index f338f524b9..3a3bdc3e4a 100644 --- a/src/mbgl/util/chrono.cpp +++ b/src/mbgl/util/chrono.cpp @@ -3,6 +3,13 @@ #include <parsedate/parsedate.h> #include <cstdio> +#include <ctime> + +#if defined(_WINDOWS) +#define _gmtime(t, i) gmtime_s(i, t) +#else +#define _gmtime(t, i) gmtime_r(t, i) +#endif namespace mbgl { namespace util { @@ -14,7 +21,7 @@ static const char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", std::string rfc1123(Timestamp timestamp) { std::time_t time = std::chrono::system_clock::to_time_t(timestamp); std::tm info; - gmtime_r(&time, &info); + _gmtime(&time, &info); char buffer[30]; snprintf(buffer, 30, "%s, %02d %s %4d %02d:%02d:%02d GMT", week[info.tm_wday], info.tm_mday, months[info.tm_mon], 1900 + info.tm_year, info.tm_hour, info.tm_min, info.tm_sec); @@ -24,7 +31,7 @@ std::string rfc1123(Timestamp timestamp) { std::string iso8601(Timestamp timestamp) { std::time_t time = std::chrono::system_clock::to_time_t(timestamp); std::tm info; - gmtime_r(&time, &info); + _gmtime(&time, &info); char buffer[30]; std::strftime(buffer, sizeof(buffer), "%F %T", &info); return buffer; |