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