mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-05 19:43:30 +01:00
Added windows-specific fixes, because strftime's implementation is different.
This commit is contained in:
parent
c268cea41d
commit
9c6ab62b86
@ -16,6 +16,7 @@
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctime>
|
||||
#include <cstring>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
@ -88,16 +89,26 @@ namespace Catch {
|
||||
else
|
||||
xml.writeAttribute( "time", suiteTime );
|
||||
|
||||
time_t rawtime;
|
||||
struct tm * timeinfo;
|
||||
const size_t timestampLength = 33;
|
||||
char iso8601Timestamp[timestampLength];
|
||||
#ifdef CATCH_PLATFORM_WINDOWS
|
||||
// %z does not return the offset from UTC with MSVC's strftime implementation
|
||||
// Timestamps will look like: "2014-01-14T17:22:09"
|
||||
const size_t timestampLength = 20;
|
||||
const char fmt[] = "%Y-%m-%dT%H:%M:%S";
|
||||
#else
|
||||
// on posix systems, we can have the full timestamp (tested with gcc and clang)
|
||||
const size_t timestampLength = 26;
|
||||
const char fmt[] = "%Y-%m-%dT%T%z";
|
||||
#endif
|
||||
char timestampStr[timestampLength];
|
||||
memset(timestampStr, 0, timestampLength);
|
||||
|
||||
time(&rawtime);
|
||||
timeinfo = localtime(&rawtime);
|
||||
|
||||
strftime (iso8601Timestamp,timestampLength, "%Y-%m-%dT%T%z", timeinfo);
|
||||
xml.writeAttribute( "timestamp", iso8601Timestamp );
|
||||
size_t ret = strftime(timestampStr,timestampLength, fmt, timeinfo);
|
||||
assert(ret != 0);
|
||||
|
||||
xml.writeAttribute( "timestamp", timestampStr );
|
||||
|
||||
// Write test cases
|
||||
for( TestGroupNode::ChildNodes::const_iterator
|
||||
|
Loading…
Reference in New Issue
Block a user