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 
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
void msg(const char *fmt,...)
Definition: message.cpp:107
std::string string
Definition: nybbler.cc:12
std::uint64_t DBTimeStamp_t
string tmp
Definition: languages.py:63
Filters for channels, events, etc.
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)
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34