00001
00002 #ifndef UTIL_LCTIME_H
00003 #define UTIL_LCTIME_H 1
00004
00005 #include "LCIOTypes.h"
00006
00007 namespace UTIL {
00008
00019 class LCTime {
00020
00021 public:
00024 struct CalendarTime{
00025 short year{0} ;
00026 short month{0} ;
00027 short day{0} ;
00028 short hour{0} ;
00029 short min{0} ;
00030 short sec{0} ;
00031 int ns{0} ;
00032 } ;
00033
00034 public:
00035
00038 LCTime() ;
00039
00042 LCTime( EVENT::long64 time ) ;
00043
00046 LCTime(int year, int month, int day, int hour=0, int min=0, int s=0 ) ;
00047
00050 LCTime( int unixTime ) ;
00051
00052
00055 int unixTime() const { return ( _t / 1000000000LL ) ; }
00056
00059 EVENT::long64 timeStamp() const { return _t ; }
00060
00061
00066 bool isLeapYear( int y ) const { return ( ( !( y % 4 ) && ( y%100 ) ) || !(y%400) ) ; }
00067
00069 int daysInYear( int y ) const ;
00070
00072 int daysInMonth( int m , int y ) const ;
00073
00077 std::string getDateString() const ;
00078
00081 const CalendarTime& calendarTime() const { return _d ; }
00082
00084 int year() const { return _d.year ; }
00085
00087 int month() const { return _d.month ; }
00088
00090 int day() const { return _d.day ; }
00091
00093 int hour() const { return _d.hour ; }
00094
00096 int min() const { return _d.min ; }
00097
00099 int sec() const { return _d.sec ; }
00100
00102 int ns() const { return _d.ns ; }
00103
00106 void operator+=(EVENT::long64 t) ;
00107
00108
00109 virtual ~LCTime() { ; }
00110
00111
00115 static bool test( int nDates ) ;
00116
00117 protected:
00118
00119 EVENT::long64 _t{0} ;
00120 CalendarTime _d{} ;
00121
00122
00123
00124 void convertToCalTime() ;
00125
00126 void convertFromCalTime() ;
00127
00128 static int dpm[13] ;
00129
00130 };
00131
00132
00133 }
00134
00135 #endif