LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lariov::TimeStampDecoder Class Reference

#include "TimeStampDecoder.h"

Public Member Functions

 TimeStampDecoder ()
 
virtual ~TimeStampDecoder ()
 

Static Public Member Functions

static IOVTimeStamp DecodeTimeStamp (DBTimeStamp_t ts)
 

Detailed Description

Definition at line 9 of file TimeStampDecoder.h.

Constructor & Destructor Documentation

lariov::TimeStampDecoder::TimeStampDecoder ( )
inline

Definition at line 12 of file TimeStampDecoder.h.

References DecodeTimeStamp(), and ~TimeStampDecoder().

12 {}
virtual lariov::TimeStampDecoder::~TimeStampDecoder ( )
virtual

Referenced by TimeStampDecoder().

Member Function Documentation

IOVTimeStamp lariov::TimeStampDecoder::DecodeTimeStamp ( DBTimeStamp_t  ts)
static

Definition at line 10 of file TimeStampDecoder.cxx.

References lariov::IOVTimeStamp::GetFromString(), lariov::kMAX_SUBSTAMP_LENGTH, tmp, and util::to_string().

Referenced by TimeStampDecoder(), and lariov::DBFolder::UpdateData().

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
24  IOVTimeStamp tmp = IOVTimeStamp::GetFromString(time);
25  return tmp;
26  }
27  else if (time.length() < kMAX_SUBSTAMP_LENGTH && ts != 0) {
28  IOVTimeStamp tmp = IOVTimeStamp::GetFromString(time);
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  }
Float_t tmp
Definition: plot.C:35
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
const unsigned short kMAX_SUBSTAMP_LENGTH
static IOVTimeStamp GetFromString(const std::string &ts)

The documentation for this class was generated from the following files: