| 12083 | |
| 12084 | namespace { |
| 12085 | std::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 | |
| 12111 | std::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() == '#'; }); |