MCPcopy Create free account
hub / github.com/CodingGay/BlackDex / getCurrentTimestamp

Function getCurrentTimestamp

Bcore/src/main/cpp/Dobby/tests/catch.hpp:12085–12109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12083
12084namespace {
12085std::string getCurrentTimestamp() {
12086 // Beware, this is not reentrant because of backward compatibility issues
12087 // Also, UTC only, again because of backward compatibility (%z is C++11)
12088 time_t rawtime;
12089 std::time(&rawtime);
12090 auto const timeStampSize = sizeof("2017-01-16T17:06:45Z");
12091
12092#ifdef _MSC_VER
12093 std::tm timeInfo = {};
12094 gmtime_s(&timeInfo, &rawtime);
12095#else
12096 std::tm *timeInfo;
12097 timeInfo = std::gmtime(&rawtime);
12098#endif
12099
12100 char timeStamp[timeStampSize];
12101 const char *const fmt = "%Y-%m-%dT%H:%M:%SZ";
12102
12103#ifdef _MSC_VER
12104 std::strftime(timeStamp, timeStampSize, fmt, &timeInfo);
12105#else
12106 std::strftime(timeStamp, timeStampSize, fmt, timeInfo);
12107#endif
12108 return std::string(timeStamp);
12109}
12110
12111std::string fileNameTag(const std::vector<std::string> &tags) {
12112 auto it = std::find_if(begin(tags), end(tags), [](std::string const &tag) { return tag.front() == '#'; });

Callers 1

writeGroupMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected