MCPcopy Create free account
hub / github.com/catchorg/Catch2 / formatTimeT

Function formatTimeT

extras/catch_amalgamated.cpp:2064–2086  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2062 }
2063
2064 std::string formatTimeT(std::time_t time) {
2065#ifdef _MSC_VER
2066 std::tm timeInfo = {};
2067 const auto err = gmtime_s( &timeInfo, &time );
2068 if ( err ) {
2069 return "gmtime from provided timepoint has failed. This "
2070 "happens e.g. with pre-1970 dates using Microsoft libc";
2071 }
2072#else
2073 std::tm* timeInfo = std::gmtime( &time );
2074#endif
2075
2076 auto const timeStampSize = sizeof( "2017-01-16T17:06:45Z" );
2077 char timeStamp[timeStampSize];
2078 const char* const fmt = "%Y-%m-%dT%H:%M:%SZ";
2079
2080#ifdef _MSC_VER
2081 std::strftime( timeStamp, timeStampSize, fmt, &timeInfo );
2082#else
2083 std::strftime( timeStamp, timeStampSize, fmt, timeInfo );
2084#endif
2085 return std::string( timeStamp, timeStampSize - 1 );
2086 }
2087
2088 std::string convertIntoString(StringRef string, bool escapeInvisibles) {
2089 std::string ret;

Callers 1

convertMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected