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 <UTIL/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. | |
LCTime (EVENT::long64 time) | |
Init from 64 bit time stamp ( ns since 1.1.1970 00:00:00 ). | |
LCTime (int year, int month, int day, int hour=0, int min=0, int s=0) | |
Init from date and time. | |
LCTime (int unixTime) | |
Init from unix time ( s since 1.1.1970 00:00:00 ). | |
int | unixTime () const |
Unix time ( s since 1.1.1970 00:00:00 ). | |
EVENT::long64 | timeStamp () const |
64bit time stamp as used in LCEvent::getTimestamp(). | |
bool | isLeapYear (int year) 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. | |
int | daysInYear (int year) const |
The number if days in the given year in the Gregorian calendar. More... | |
int | daysInMonth (int month, int year) 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. | |
int | year () const |
Calendar time: year. | |
int | month () const |
Calendar time: month. | |
int | day () const |
Calendar time: day. | |
int | hour () const |
Calendar time: hour. | |
int | min () const |
Calendar time: min. | |
int | sec () const |
Calendar time: sec. | |
int | ns () const |
Calendar time: ns. | |
void | operator+= (EVENT::long64 t) |
Add the specified number of ns to the time. | |
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. | |
Protected Member Functions | |
void | convertToCalTime () |
void | convertFromCalTime () |
Protected Attributes | |
EVENT::long64 | _t |
CalendarTime | _d |
Static Protected Attributes | |
static 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.
int UTIL::LCTime::daysInMonth | ( | int | month, |
int | year | ||
) | const |
The number if days in the given month and year in the Gregorian calendar.
References isLeapYear(), and month().
int UTIL::LCTime::daysInYear | ( | int | year | ) | const |
The number if days in the given year in the Gregorian calendar.
References isLeapYear().
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
Referenced by UTIL::LCTOOLS::dumpEventDetailed(), LCTime(), and test().