| 16806 | |
| 16807 | namespace { |
| 16808 | std::string getCurrentTimestamp() { |
| 16809 | // Beware, this is not reentrant because of backward compatibility issues |
| 16810 | // Also, UTC only, again because of backward compatibility (%z is C++11) |
| 16811 | time_t rawtime; |
| 16812 | std::time(&rawtime); |
| 16813 | auto const timeStampSize = sizeof("2017-01-16T17:06:45Z"); |
| 16814 | |
| 16815 | #ifdef _MSC_VER |
| 16816 | std::tm timeInfo = {}; |
| 16817 | gmtime_s(&timeInfo, &rawtime); |
| 16818 | #else |
| 16819 | std::tm* timeInfo; |
| 16820 | timeInfo = std::gmtime(&rawtime); |
| 16821 | #endif |
| 16822 | |
| 16823 | char timeStamp[timeStampSize]; |
| 16824 | const char * const fmt = "%Y-%m-%dT%H:%M:%SZ"; |
| 16825 | |
| 16826 | #ifdef _MSC_VER |
| 16827 | std::strftime(timeStamp, timeStampSize, fmt, &timeInfo); |
| 16828 | #else |
| 16829 | std::strftime(timeStamp, timeStampSize, fmt, timeInfo); |
| 16830 | #endif |
| 16831 | return std::string(timeStamp, timeStampSize-1); |
| 16832 | } |
| 16833 | |
| 16834 | std::string fileNameTag(const std::vector<std::string> &tags) { |
| 16835 | auto it = std::find_if(begin(tags), |