diff options
| author | Martin Hořeňovský | 2021-01-27 19:55:41 +0100 |
|---|---|---|
| committer | GitHub | 2021-01-27 19:55:41 +0100 |
| commit | 2dbe63a6ba949c3f0a2078770f7d12cfe5adc10c (patch) | |
| tree | 5143dd1560239325a0497d336e1386b69c5756b1 | |
| parent | b435e391c45c7cdb23c35cd2afb3435b0b7e53c7 (diff) | |
| parent | 477540760a84bab3ae08c9ffc3be065d09daf239 (diff) | |
| download | catch3-2dbe63a6ba949c3f0a2078770f7d12cfe5adc10c.tar.gz | |
Merge pull request #2165 from catchorg/devel-gmtime-fixup
Use gmtime_r instead of gmtime when compiling for posixy platforms
| -rw-r--r-- | src/catch2/reporters/catch_reporter_junit.cpp | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/catch2/reporters/catch_reporter_junit.cpp b/src/catch2/reporters/catch_reporter_junit.cpp index eb460966..cff5d7d7 100644 --- a/src/catch2/reporters/catch_reporter_junit.cpp +++ b/src/catch2/reporters/catch_reporter_junit.cpp @@ -22,28 +22,22 @@ namespace Catch { namespace { std::string getCurrentTimestamp() { - // Beware, this is not reentrant because of backward compatibility issues - // Also, UTC only, again because of backward compatibility (%z is C++11) time_t rawtime; std::time(&rawtime); - auto const timeStampSize = sizeof("2017-01-16T17:06:45Z"); -#ifdef _MSC_VER std::tm timeInfo = {}; +#ifdef _MSC_VER gmtime_s(&timeInfo, &rawtime); #else - std::tm* timeInfo; - timeInfo = std::gmtime(&rawtime); + gmtime_r(&rawtime, &timeInfo); #endif + auto const timeStampSize = sizeof("2017-01-16T17:06:45Z"); char timeStamp[timeStampSize]; const char * const fmt = "%Y-%m-%dT%H:%M:%SZ"; -#ifdef _MSC_VER std::strftime(timeStamp, timeStampSize, fmt, &timeInfo); -#else - std::strftime(timeStamp, timeStampSize, fmt, timeInfo); -#endif + return std::string(timeStamp); } |