Diana Software
QTime.cc
Go to the documentation of this file.
1 /* Diana Reconstruction program
2  *
3  * Authors: Marco Vignati and Riccardo Faccini 6/3/07
4  *
5  * Class QTime
6  *
7 */
8 
9 #include "QTime.hh"
10 
11 QObjectImp(Diana::QTime);
12 
14 
15 
17 {
18 }
19 
21 {
22 }
23 
25 {
26  fFromStartRunNs = 0ULL;
27  fStartRunUnix = 0;
28 }
29 
30 void QTime::SetStartRunUnix(int year, int month, int day, int hour, int min, int sec) {
31  tm date;
32  date.tm_sec=sec;
33  date.tm_min=min;
34  date.tm_hour=hour;
35  date.tm_mday=day;
36  date.tm_mon=month-1;
37  date.tm_year=year-1900;
38 
39  // try to determine automatically whether daylight saving time is in effect
40  date.tm_isdst = -1;
41 
42  fStartRunUnix=mktime(&date);
43 }
44 
45 void QTime::Dump(std::ostream& o) const
46 {
47  time_t start(this->GetStartRunUnix());
48  std::string t( ctime( &start ) );
49 
50  o<<"Run start ["<< t.substr( 0, t.length() -1 )<< "] Time ["<<this->GetFromStartRunNs()/1e09<<"s]";
51 }
52 
53 bool QTime::operator==(const QTime& other) const
54 {
55  return (fFromStartRunNs == other.fFromStartRunNs && fStartRunUnix == other.fStartRunUnix);
56 
57 }
58 
59 bool QTime::operator<(const QTime& other) const
60 {
61  return ( (fStartRunUnix*1e9 + fFromStartRunNs) <
62  (other.fStartRunUnix*1e9 + other.fFromStartRunNs) );
63 }
64 
#define Q_END_NAMESPACE
Definition: QDiana.hh:22
#define Q_BEGIN_NAMESPACE
Definition: QDiana.hh:20
QObjectImp(Diana::QTime)
double min(const Diana::QVector &v)
Definition: QVector.cc:878
Diana time.
Definition: QTime.hh:17
unsigned long long fFromStartRunNs
Definition: QTime.hh:66
unsigned long long GetFromStartRunNs() const
retrieve time from start of run in ns
Definition: QTime.hh:38
void SetStartRunUnix(unsigned int time)
set time of start of run in seconds from 1/1/1970
Definition: QTime.hh:32
time_t GetStartRunUnix() const
retrieve time of start of run in seconds from 1/1/1970
Definition: QTime.hh:41
unsigned int fStartRunUnix
Definition: QTime.hh:67
void Dump(std::ostream &o) const
dump object
Definition: QTime.cc:45
QTime()
default constructor
Definition: QTime.cc:16
void Clear()
clear values
Definition: QTime.cc:24
virtual ~QTime()
default destructor
Definition: QTime.cc:20
bool operator<(const QTime &other) const
operator<
Definition: QTime.cc:59
bool operator==(const QTime &other) const
operator==
Definition: QTime.cc:53