Static Public Member Functions | List of all members
DuneTimeConverter Class Reference

#include <DuneTimeConverter.h>

Static Public Member Functions

static uint64_t novaT0Sec ()
 
static uint64_t novaTicksPerUsec ()
 
static uint64_t novaTicksPerSec ()
 
static art::Timestamp fromNova (uint64_t tnova)
 
static uint64_t toNova (art::Timestamp tart)
 
static art::Timestamp makeTimestamp (uint32_t tsec, uint32_t trem)
 
static std::string toString (art::Timestamp tart)
 
static art::Timestamp fromString (std::string stime)
 

Detailed Description

Definition at line 21 of file DuneTimeConverter.h.

Member Function Documentation

art::Timestamp DuneTimeConverter::fromNova ( uint64_t  tnova)
static

Definition at line 15 of file DuneTimeConverter.cxx.

15  {
16  const uint64_t nsecPerUsec = 1000;
17  uint64_t secSinceNovaT0 = novaTime/novaTicksPerSec();
18  uint64_t ticksRem = novaTime - novaTicksPerSec()*secSinceNovaT0;
19  uint64_t sec = secSinceNovaT0 + novaT0Sec();
20  uint64_t nsec = (ticksRem*nsecPerUsec)/novaTicksPerUsec();
21  uint64_t tart = (sec << 32) + nsec;
22  art::Timestamp ts(tart);
23  return ts;
24 }
static uint64_t novaTicksPerSec()
static uint64_t novaT0Sec()
static uint64_t novaTicksPerUsec()
art::Timestamp DuneTimeConverter::fromString ( std::string  stime)
static

Definition at line 55 of file DuneTimeConverter.cxx.

55  {
56  string::size_type ipos = stime.find(".");
57  if ( ipos != string::npos ) ++ipos;
58  while ( ipos < stime.size() && stime[ipos] == '0' ) ++ipos;
59  bool hasns = ipos < stime.size();
60  uint32_t tsec;
61  istringstream sssec(stime.substr(0,ipos));
62  sssec >> tsec;
63  uint32_t tns = 0;
64  if ( hasns ) {
65  istringstream ssns(stime.substr(ipos));
66  ssns >> tns;
67  }
68  return makeTimestamp(tsec, tns);
69 }
static art::Timestamp makeTimestamp(uint32_t tsec, uint32_t trem)
art::Timestamp DuneTimeConverter::makeTimestamp ( uint32_t  tsec,
uint32_t  trem 
)
static

Definition at line 37 of file DuneTimeConverter.cxx.

37  {
38  uint64_t tthi = tsec;
39  uint64_t thilo = (tthi << 32) + tns;
40  return art::Timestamp(thilo);
41 }
static uint64_t DuneTimeConverter::novaT0Sec ( )
inlinestatic

Definition at line 25 of file DuneTimeConverter.h.

25  {
26  return 1262304000; // 01Jan2010 UTC in unix time
27  }
static uint64_t DuneTimeConverter::novaTicksPerSec ( )
inlinestatic

Definition at line 35 of file DuneTimeConverter.h.

35  {
36  return 1000000*novaTicksPerUsec();
37  }
static uint64_t novaTicksPerUsec()
static uint64_t DuneTimeConverter::novaTicksPerUsec ( )
inlinestatic

Definition at line 30 of file DuneTimeConverter.h.

30  {
31  return 64;
32  }
uint64_t DuneTimeConverter::toNova ( art::Timestamp  tart)
static

Definition at line 28 of file DuneTimeConverter.cxx.

28  {
29  uint64_t thi = tart.timeHigh();
30  uint64_t tlo = tart.timeLow();
31  uint64_t tnova = novaTicksPerSec()*(thi - novaT0Sec()) + (tlo*novaTicksPerUsec())/1000;
32  return tnova;
33 }
constexpr std::uint32_t timeLow() const
Definition: Timestamp.h:29
constexpr std::uint32_t timeHigh() const
Definition: Timestamp.h:34
static uint64_t novaTicksPerSec()
static uint64_t novaT0Sec()
static uint64_t novaTicksPerUsec()
string DuneTimeConverter::toString ( art::Timestamp  tart)
static

Definition at line 45 of file DuneTimeConverter.cxx.

45  {
46  ostringstream sstime;
47  sstime << tart.timeHigh();
48  sstime << ".";
49  sstime << setw(9) << setfill('0') << tart.timeLow();
50  return sstime.str();
51 }
constexpr std::uint32_t timeLow() const
Definition: Timestamp.h:29
constexpr std::uint32_t timeHigh() const
Definition: Timestamp.h:34
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
Q_EXPORT QTSManip setfill(int f)
Definition: qtextstream.h:337

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