LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
TimeStampDecoder.cxx
Go to the documentation of this file.
1 #include "TimeStampDecoder.h"
2 #include "IOVDataConstants.h"
3 #include "IOVDataError.h"
4 #include <string>
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 
13  std::string time = std::to_string(ts);
14 
15  //microboone stores timestamp as ns from epoch, so there should be 19 digits.
16  if (time.length() == 19) {
17  //make timestamp conform to database precision
18  time = time.substr(0, 10 + kMAX_SUBSTAMP_LENGTH);
19 
20  //insert decimal point
21  time.insert(10, ".");
22 
23  //finish construction
25  return tmp;
26  }
27  else if (time.length() < kMAX_SUBSTAMP_LENGTH && ts != 0) {
29  return tmp;
30  }
31  else {
32  std::string msg = "TimeStampDecoder: I do not know how to convert this timestamp: " + time;
33  throw IOVDataError(msg);
34  }
35  }
36 } //end namespace lariov
Float_t tmp
Definition: plot.C:35
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
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)