CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/RecoLuminosity/TCPReceiver/src/TimeStamp.cc

Go to the documentation of this file.
00001 #include "RecoLuminosity/TCPReceiver/interface/TimeStamp.h"
00002 
00003 #include <sstream>
00004 #include <iomanip>
00005 
00006 std::string HCAL_HLX::TimeStamp::TimeStampLong( time_t rawtime ){
00007 
00008   if( rawtime == 0 )
00009     time(&rawtime);
00010 
00011   return ctime(&rawtime);
00012 }
00013 
00014 std::string HCAL_HLX::TimeStamp::TimeStampYYYYMM( time_t rawtime ){
00015 
00016   std::string tempStr = TimeStampYYYYMMDD( rawtime );
00017   return tempStr.substr(0,6);
00018 }
00019 
00020 std::string HCAL_HLX::TimeStamp::TimeStampYYYYMMDD( time_t rawtime ){
00021 
00022   if( rawtime == 0 ) 
00023     time(&rawtime);
00024 
00025   struct tm* timeinfo;
00026   timeinfo = localtime(&rawtime);
00027 
00028   std::ostringstream out;
00029   out.str(std::string());
00030   out << std::setfill('0') << std::setw(4) << timeinfo->tm_year + 1900;
00031   out << std::setfill('0') << std::setw(2) << timeinfo->tm_mon + 1;
00032   out << std::setfill('0') << std::setw(2) << timeinfo->tm_mday;
00033 
00034   return out.str();
00035 }