Skip to content

Commit

Permalink
replace missing gmtime_r on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
alex85k committed Aug 20, 2014
1 parent e76438d commit c951857
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions include/osmium/osm/timestamp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ DEALINGS IN THE SOFTWARE.
#include <limits>
#include <stdexcept>
#include <string>
#include <time.h>

namespace osmium {

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c951857

Please sign in to comment.