LCIO
02.17
|
Helper class that allows to convert time stamps as defined in LCEvent::getTimeStamp() ( ns since 1.1.1970 00:00:00 UTC) to ordinary date and time and vice versa. More...
#include <LCTime.h>
Classes | |
struct | CalendarTime |
Helper struct that holds the calendar time. More... | |
Public Member Functions | |
LCTime () | |
Init with current time ( accuracy depends on OS/machine,etc.) in UTC/GMT. More... | |
LCTime (EVENT::long64 time) | |
Init from 64 bit time stamp ( ns since 1.1.1970 00:00:00 ). More... | |
LCTime (int year, int month, int day, int hour=0, int min=0, int s=0) | |
Init from date and time. More... | |
LCTime (int unixTime) | |
Init from unix time ( s since 1.1.1970 00:00:00 ). More... | |
int | unixTime () const |
Unix time ( s since 1.1.1970 00:00:00 ). More... | |
EVENT::long64 | timeStamp () const |
64bit time stamp as used in LCEvent::getTimestamp(). More... | |
bool | isLeapYear (int y) const |
True if the year is a leap year in the Gregorian calendar: year is multiple of 4 and not multiple of 100 or year is multiple of 400. More... | |
int | daysInYear (int y) const |
The number if days in the given year in the Gregorian calendar. More... | |
int | daysInMonth (int m, int y) const |
The number if days in the given month and year in the Gregorian calendar. More... | |
std::string | getDateString () const |
Date in human readable format, e.g. More... | |
const CalendarTime & | calendarTime () const |
Calendar time: year,month,day hour,min,sec and ns. More... | |
int | year () const |
Calendar time: year. More... | |
int | month () const |
Calendar time: month. More... | |
int | day () const |
Calendar time: day. More... | |
int | hour () const |
Calendar time: hour. More... | |
int | min () const |
Calendar time: min. More... | |
int | sec () const |
Calendar time: sec. More... | |
int | ns () const |
Calendar time: ns. More... | |
void | operator+= (EVENT::long64 t) |
Add the specified number of ns to the time. More... | |
virtual | ~LCTime () |
Static Public Member Functions | |
static bool | test (int nDates) |
Tests the LCTime class with nDates random dates Returns true if successful - throws Exception in case of error. More... | |
Protected Member Functions | |
void | convertToCalTime () |
void | convertFromCalTime () |
Protected Attributes | |
EVENT::long64 | _t {0} |
CalendarTime | _d {} |
Static Protected Attributes | |
static const int | dpm [13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 } |
Helper class that allows to convert time stamps as defined in LCEvent::getTimeStamp() ( ns since 1.1.1970 00:00:00 UTC) to ordinary date and time and vice versa.
Dates and times are in UTC/GMT by default.
Negative time stamps are not supported and mapped to 0LL and 1.1.1970 00:00:00 UTC respectively.
UTIL::LCTime::LCTime | ( | ) |
Init with current time ( accuracy depends on OS/machine,etc.) in UTC/GMT.
Definition at line 30 of file LCTime.cc.
References NPS, and std::time().
UTIL::LCTime::LCTime | ( | EVENT::long64 | time | ) |
Init from 64 bit time stamp ( ns since 1.1.1970 00:00:00 ).
Definition at line 58 of file LCTime.cc.
References convertToCalTime().
UTIL::LCTime::LCTime | ( | int | year, |
int | month, | ||
int | day, | ||
int | hour = 0 , |
||
int | min = 0 , |
||
int | s = 0 |
||
) |
Init from date and time.
Definition at line 64 of file LCTime.cc.
References _d, convertFromCalTime(), UTIL::LCTime::CalendarTime::day, daysInMonth(), getDateString(), UTIL::LCTime::CalendarTime::hour, UTIL::LCTime::CalendarTime::min, UTIL::LCTime::CalendarTime::month, UTIL::LCTime::CalendarTime::ns, UTIL::LCTime::CalendarTime::sec, UTIL::LCTime::CalendarTime::year, and YEAR0.
UTIL::LCTime::LCTime | ( | int | unixTime | ) |
Init from unix time ( s since 1.1.1970 00:00:00 ).
Definition at line 87 of file LCTime.cc.
References _t, convertToCalTime(), and NPS.
|
inline |
|
protected |
Definition at line 165 of file LCTime.cc.
References _d, _t, convertToCalTime(), UTIL::LCTime::CalendarTime::day, daysInMonth(), daysInYear(), UTIL::LCTime::CalendarTime::hour, UTIL::LCTime::CalendarTime::min, UTIL::LCTime::CalendarTime::month, NPS, UTIL::LCTime::CalendarTime::sec, SPD, SPH, SPM, UTIL::LCTime::CalendarTime::year, and YEAR0.
Referenced by LCTime().
|
protected |
Definition at line 96 of file LCTime.cc.
References _d, _t, UTIL::LCTime::CalendarTime::day, daysInMonth(), daysInYear(), UTIL::LCTime::CalendarTime::hour, UTIL::LCTime::CalendarTime::min, UTIL::LCTime::CalendarTime::month, NPS, UTIL::LCTime::CalendarTime::ns, UTIL::LCTime::CalendarTime::sec, SPD, SPH, SPM, UTIL::LCTime::CalendarTime::year, and YEAR0.
Referenced by convertFromCalTime(), LCTime(), and operator+=().
|
inline |
Calendar time: day.
Definition at line 90 of file LCTime.h.
References _d, and UTIL::LCTime::CalendarTime::day.
Referenced by test().
int UTIL::LCTime::daysInMonth | ( | int | m, |
int | y | ||
) | const |
The number if days in the given month and year in the Gregorian calendar.
Definition at line 202 of file LCTime.cc.
References dpm, and isLeapYear().
Referenced by convertFromCalTime(), convertToCalTime(), LCTime(), and test().
int UTIL::LCTime::daysInYear | ( | int | y | ) | const |
The number if days in the given year in the Gregorian calendar.
Definition at line 196 of file LCTime.cc.
References DPY, and isLeapYear().
Referenced by convertFromCalTime(), and convertToCalTime().
std::string UTIL::LCTime::getDateString | ( | ) | const |
Date in human readable format, e.g.
10.02.2005 10:54:29.123456789 :
dd.mm.yyyy hh:mm:ss._ms_us_ns
Definition at line 220 of file LCTime.cc.
References _d, UTIL::LCTime::CalendarTime::day, UTIL::LCTime::CalendarTime::hour, UTIL::LCTime::CalendarTime::min, UTIL::LCTime::CalendarTime::month, UTIL::LCTime::CalendarTime::ns, UTIL::LCTime::CalendarTime::sec, std::setfill(), std::setw(), std::stringstream::str(), and UTIL::LCTime::CalendarTime::year.
|
inline |
Calendar time: hour.
Definition at line 93 of file LCTime.h.
References _d, and UTIL::LCTime::CalendarTime::hour.
Referenced by test().
|
inline |
True if the year is a leap year in the Gregorian calendar:
year is multiple of 4 and not multiple of 100
or year is multiple of 400.
Definition at line 66 of file LCTime.h.
Referenced by daysInMonth(), and daysInYear().
|
inline |
Calendar time: min.
Definition at line 96 of file LCTime.h.
References _d, and UTIL::LCTime::CalendarTime::min.
Referenced by test().
|
inline |
Calendar time: month.
Definition at line 87 of file LCTime.h.
References _d, and UTIL::LCTime::CalendarTime::month.
Referenced by test().
|
inline |
Calendar time: ns.
Definition at line 102 of file LCTime.h.
References _d, and UTIL::LCTime::CalendarTime::ns.
Referenced by test().
void UTIL::LCTime::operator+= | ( | EVENT::long64 | t | ) |
Add the specified number of ns to the time.
Definition at line 213 of file LCTime.cc.
References _t, and convertToCalTime().
|
inline |
Calendar time: sec.
Definition at line 99 of file LCTime.h.
References _d, and UTIL::LCTime::CalendarTime::sec.
Referenced by test().
|
static |
Tests the LCTime class with nDates random dates Returns true if successful - throws Exception in case of error.
Definition at line 244 of file LCTime.cc.
References UTIL::LCTime::CalendarTime::day, day(), daysInMonth(), std::endl(), getDateString(), UTIL::LCTime::CalendarTime::hour, hour(), UTIL::LCTime::CalendarTime::min, min(), UTIL::LCTime::CalendarTime::month, month(), UTIL::LCTime::CalendarTime::ns, ns(), std::rand(), UTIL::LCTime::CalendarTime::sec, sec(), std::setfill(), std::setw(), timeStamp(), UTIL::LCTime::CalendarTime::year, year(), and YEAR0.
|
inline |
|
inline |
|
inline |
Calendar time: year.
Definition at line 84 of file LCTime.h.
References _d, and UTIL::LCTime::CalendarTime::year.
Referenced by test().
|
protected |
Definition at line 120 of file LCTime.h.
Referenced by calendarTime(), convertFromCalTime(), convertToCalTime(), day(), getDateString(), hour(), LCTime(), min(), month(), ns(), sec(), and year().
|
protected |
Definition at line 119 of file LCTime.h.
Referenced by convertFromCalTime(), convertToCalTime(), LCTime(), operator+=(), timeStamp(), and unixTime().
|
staticprotected |
Definition at line 128 of file LCTime.h.
Referenced by daysInMonth().