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 <assert.h>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
@ -88,16 +89,26 @@ namespace Catch {
|
|||||||
else
|
else
|
||||||
xml.writeAttribute( "time", suiteTime );
|
xml.writeAttribute( "time", suiteTime );
|
||||||
|
|
||||||
time_t rawtime;
|
#ifdef CATCH_PLATFORM_WINDOWS
|
||||||
struct tm * timeinfo;
|
// %z does not return the offset from UTC with MSVC's strftime implementation
|
||||||
const size_t timestampLength = 33;
|
// Timestamps will look like: "2014-01-14T17:22:09"
|
||||||
char iso8601Timestamp[timestampLength];
|
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);
|
time(&rawtime);
|
||||||
timeinfo = localtime(&rawtime);
|
timeinfo = localtime(&rawtime);
|
||||||
|
|
||||||
strftime (iso8601Timestamp,timestampLength, "%Y-%m-%dT%T%z", timeinfo);
|
size_t ret = strftime(timestampStr,timestampLength, fmt, timeinfo);
|
||||||
xml.writeAttribute( "timestamp", iso8601Timestamp );
|
assert(ret != 0);
|
||||||
|
|
||||||
|
xml.writeAttribute( "timestamp", timestampStr );
|
||||||
|
|
||||||
// Write test cases
|
// Write test cases
|
||||||
for( TestGroupNode::ChildNodes::const_iterator
|
for( TestGroupNode::ChildNodes::const_iterator
|
||||||
|
Loading…
Reference in New Issue
Block a user