CMS 3D CMS Logo

TimeStamp.cc
Go to the documentation of this file.
2 
3 #include <sstream>
4 #include <iomanip>
5 
7  if (rawtime == 0)
8  time(&rawtime);
9 
10  return ctime(&rawtime);
11 }
12 
14  std::string tempStr = TimeStampYYYYMMDD(rawtime);
15  return tempStr.substr(0, 6);
16 }
17 
19  if (rawtime == 0)
20  time(&rawtime);
21 
22  struct tm* timeinfo;
23  timeinfo = localtime(&rawtime);
24 
25  std::ostringstream out;
26  out.str(std::string());
27  out << std::setfill('0') << std::setw(4) << timeinfo->tm_year + 1900;
28  out << std::setfill('0') << std::setw(2) << timeinfo->tm_mon + 1;
29  out << std::setfill('0') << std::setw(2) << timeinfo->tm_mday;
30 
31  return out.str();
32 }
std::string TimeStampYYYYMM(time_t rawtime=0)
Definition: TimeStamp.cc:13
std::string TimeStampLong(time_t rawtime=0)
Definition: TimeStamp.cc:6
std::string TimeStampYYYYMMDD(time_t rawtime=0)
Definition: TimeStamp.cc:18