File indexing completed on 2023-03-17 11:20:01
0001 #include "RecoLuminosity/TCPReceiver/interface/TimeStamp.h"
0002
0003 #include <sstream>
0004 #include <iomanip>
0005
0006 std::string HCAL_HLX::TimeStamp::TimeStampLong(time_t rawtime) {
0007 if (rawtime == 0)
0008 time(&rawtime);
0009
0010 return ctime(&rawtime);
0011 }
0012
0013 std::string HCAL_HLX::TimeStamp::TimeStampYYYYMM(time_t rawtime) {
0014 std::string tempStr = TimeStampYYYYMMDD(rawtime);
0015 return tempStr.substr(0, 6);
0016 }
0017
0018 std::string HCAL_HLX::TimeStamp::TimeStampYYYYMMDD(time_t rawtime) {
0019 if (rawtime == 0)
0020 time(&rawtime);
0021
0022 struct tm* timeinfo;
0023 timeinfo = localtime(&rawtime);
0024
0025 std::ostringstream out;
0026 out.str(std::string());
0027 out << std::setfill('0') << std::setw(4) << timeinfo->tm_year + 1900;
0028 out << std::setfill('0') << std::setw(2) << timeinfo->tm_mon + 1;
0029 out << std::setfill('0') << std::setw(2) << timeinfo->tm_mday;
0030
0031 return out.str();
0032 }