From c9518573192490873f3945f6cac791fe930e76b1 Mon Sep 17 00:00:00 2001 From: alex85k Date: Wed, 20 Aug 2014 15:01:18 +0600 Subject: [PATCH] replace missing gmtime_r on Windows --- include/osmium/osm/timestamp.hpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/include/osmium/osm/timestamp.hpp b/include/osmium/osm/timestamp.hpp index f49432677..bd2558d7f 100644 --- a/include/osmium/osm/timestamp.hpp +++ b/include/osmium/osm/timestamp.hpp @@ -39,6 +39,7 @@ DEALINGS IN THE SOFTWARE. #include #include #include +#include namespace osmium { @@ -117,11 +118,14 @@ namespace osmium { if (m_timestamp == 0) { return std::string(""); } - struct tm tm { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; + struct tm tm; time_t sse = seconds_since_epoch(); +#ifndef _MSC_VER gmtime_r(&sse, &tm); +#else + gmtime_s(&tm, &sse); +#endif + std::string s(timestamp_length, '\0'); /* This const_cast is ok, because we know we have enough space in the string for the format we are using (well at least until