14 #define SPH 3600 // 60*60
15 #define SPD 86400 // 60*60*24
17 #define DPY 365 // days per year - no leap year
18 #define NPS 1000000000LL // ns per s - need 64bit to force result of conversion to be 64bit
20 using namespace EVENT ;
27 const int LCTime::dpm[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 } ;
58 LCTime::LCTime(
long64 time) : _t( time ) {
77 mon < 0 || mon > 12 ||
89 _t = unix_time *
NPS ;
118 int nDays = s /
SPD ;
181 for(
int m = 1 ; m <
_d.
month ; m ++ ){
185 nDays +=
_d.
day - 1 ;
204 if( mon < 1 || mon > 12 )
246 std::cout <<
"LCTime::test: test LCTime with " << nDates <<
" random dates " <<
std::endl ;
250 for(
int i=0; i<nDates;i++){
258 date.
min = int( 0 + 60 * ( 1.*
std::rand()/RAND_MAX ) ) ;
259 date.
sec = int( 0 + 60 * ( 1.*
std::rand()/RAND_MAX ) ) ;
265 (
int) date.
hour, (
int) date.
min, (
int) date.
sec ) ;
296 if( testTime0.
getDateString() != testTime1.getDateString() ){
304 if( date.
year != testTime0.
year() ||
306 date.
day != testTime0.
day() ||
308 date.
min != testTime0.
min() ||
309 date.
sec != testTime0.
sec() ||
310 date.
ns != testTime0.
ns () ) {
Base exception class for LCIO - all other exceptions extend this.
int year() const
Calendar time: year.
int sec() const
Calendar time: sec.
int daysInMonth(int m, int y) const
The number if days in the given month and year in the Gregorian calendar.
long long long64
64 bit signed integer,e.g.to be used for timestamps
Helper class that allows to convert time stamps as defined in LCEvent::getTimeStamp() ( ns since 1...
int month() const
Calendar time: month.
int ns() const
Calendar time: ns.
std::string getDateString() const
Date in human readable format, e.g.
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...
EVENT::long64 timeStamp() const
64bit time stamp as used in LCEvent::getTimestamp().
int day() const
Calendar time: day.
int hour() const
Calendar time: hour.
int min() const
Calendar time: min.
void operator+=(EVENT::long64 t)
Add the specified number of ns to the time.
static bool test(int nDates)
Tests the LCTime class with nDates random dates Returns true if successful - throws Exception in case...
LCTime()
Init with current time ( accuracy depends on OS/machine,etc.) in UTC/GMT.
Helper struct that holds the calendar time.
void convertFromCalTime()
int daysInYear(int y) const
The number if days in the given year in the Gregorian calendar.