MCPcopy Create free account
hub / github.com/ChaiScript/ChaiScript / getCurrentTimestamp

Function getCurrentTimestamp

unittests/catch.hpp:12194–12218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12192
12193 namespace {
12194 std::string getCurrentTimestamp() {
12195 // Beware, this is not reentrant because of backward compatibility issues
12196 // Also, UTC only, again because of backward compatibility (%z is C++11)
12197 time_t rawtime;
12198 std::time(&rawtime);
12199 auto const timeStampSize = sizeof("2017-01-16T17:06:45Z");
12200
12201#ifdef _MSC_VER
12202 std::tm timeInfo = {};
12203 gmtime_s(&timeInfo, &rawtime);
12204#else
12205 std::tm* timeInfo;
12206 timeInfo = std::gmtime(&rawtime);
12207#endif
12208
12209 char timeStamp[timeStampSize];
12210 const char * const fmt = "%Y-%m-%dT%H:%M:%SZ";
12211
12212#ifdef _MSC_VER
12213 std::strftime(timeStamp, timeStampSize, fmt, &timeInfo);
12214#else
12215 std::strftime(timeStamp, timeStampSize, fmt, timeInfo);
12216#endif
12217 return std::string(timeStamp);
12218 }
12219
12220 std::string fileNameTag(const std::vector<std::string> &tags) {
12221 auto it = std::find_if(begin(tags),

Callers 1

writeGroupMethod · 0.85

Calls 1

stringClass · 0.85

Tested by

no test coverage detected