All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TimeStampDecoder.cxx
Go to the documentation of this file.
1 #include <string>
2 #include "TimeStampDecoder.h"
3 #include "IOVDataConstants.h"
4 #include "IOVDataError.h"
5 
6 namespace lariov {
7 
8  //Do NOT change the following code without very good reason!
9  //MicroBooNE and other experiments depend on it!
11 
12  std::string time = std::to_string(ts);
13 
14  //microboone stores timestamp as ns from epoch, so there should be 19 digits.
15  if (time.length() == 19) {
16  //make timestamp conform to database precision
17  time = time.substr(0, 10+kMAX_SUBSTAMP_LENGTH);
18 
19  //insert decimal point
20  time.insert(10,".");
21 
22  //finish construction
24  return tmp;
25  }
26  else if (time.length() < kMAX_SUBSTAMP_LENGTH && ts!=0) {
28  return tmp;
29  }
30  else {
31  std::string msg = "TimeStampDecoder: I do not know how to convert this timestamp: " + time;
32  throw IOVDataError(msg);
33  }
34  }
35 }//end namespace lariov
std::uint64_t DBTimeStamp_t
std::string to_string(WindowPattern const &pattern)
Collection of exception classes for IOVData.
const unsigned short kMAX_SUBSTAMP_LENGTH
static IOVTimeStamp GetFromString(const std::string &ts)
static IOVTimeStamp DecodeTimeStamp(DBTimeStamp_t ts)