LCIO  02.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
UTIL::LCTime Class Reference

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 CalendarTimecalendarTime () 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 }
 

Detailed Description

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.

Author
gaede
Version
Id:
LCTime.h,v 1.4 2005-04-22 15:39:01 gaede Exp

Definition at line 19 of file LCTime.h.

Constructor & Destructor Documentation

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 
)
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.

virtual UTIL::LCTime::~LCTime ( )
inlinevirtual

Definition at line 109 of file LCTime.h.

Member Function Documentation

const CalendarTime& UTIL::LCTime::calendarTime ( ) const
inline

Calendar time: year,month,day hour,min,sec and ns.

Definition at line 81 of file LCTime.h.

References _d.

void UTIL::LCTime::convertFromCalTime ( )
protected
void UTIL::LCTime::convertToCalTime ( )
protected
int UTIL::LCTime::day ( ) const
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
int UTIL::LCTime::hour ( ) const
inline

Calendar time: hour.

Definition at line 93 of file LCTime.h.

References _d, and UTIL::LCTime::CalendarTime::hour.

Referenced by test().

bool UTIL::LCTime::isLeapYear ( int  y) const
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().

int UTIL::LCTime::min ( ) const
inline

Calendar time: min.

Definition at line 96 of file LCTime.h.

References _d, and UTIL::LCTime::CalendarTime::min.

Referenced by test().

int UTIL::LCTime::month ( ) const
inline

Calendar time: month.

Definition at line 87 of file LCTime.h.

References _d, and UTIL::LCTime::CalendarTime::month.

Referenced by test().

int UTIL::LCTime::ns ( ) const
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().

int UTIL::LCTime::sec ( ) const
inline

Calendar time: sec.

Definition at line 99 of file LCTime.h.

References _d, and UTIL::LCTime::CalendarTime::sec.

Referenced by test().

bool UTIL::LCTime::test ( int  nDates)
static
EVENT::long64 UTIL::LCTime::timeStamp ( ) const
inline

64bit time stamp as used in LCEvent::getTimestamp().

Definition at line 59 of file LCTime.h.

References _t.

Referenced by test().

int UTIL::LCTime::unixTime ( ) const
inline

Unix time ( s since 1.1.1970 00:00:00 ).

Definition at line 55 of file LCTime.h.

References _t.

int UTIL::LCTime::year ( ) const
inline

Calendar time: year.

Definition at line 84 of file LCTime.h.

References _d, and UTIL::LCTime::CalendarTime::year.

Referenced by test().

Member Data Documentation

CalendarTime UTIL::LCTime::_d {}
protected
EVENT::long64 UTIL::LCTime::_t {0}
protected

Definition at line 119 of file LCTime.h.

Referenced by convertFromCalTime(), convertToCalTime(), LCTime(), operator+=(), timeStamp(), and unixTime().

const int UTIL::LCTime::dpm = { 0,31,28,31,30,31,30,31,31,30,31,30,31 }
staticprotected

Definition at line 128 of file LCTime.h.

Referenced by daysInMonth().


The documentation for this class was generated from the following files: