EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ValTimeStamp Class Reference

#include <EicRoot/blob/master/dbase/dbValidation/ValTimeStamp.h>

Public Member Functions

 ValTimeStamp ()
 Empty ctor (builds current time with nsec field filled as best possible)
 
 ValTimeStamp (const ValTimeStamp &source)
 Copy.
 
ValTimeStampoperator= (const ValTimeStamp &source)
 Assignment.
 
 ValTimeStamp (const timespec_t &ts)
 Construction from timespec struct.
 
 ValTimeStamp (const time_t &t, const Int_t nsec)
 Construction from time_t and separate nsec.
 
 ValTimeStamp (UInt_t year, UInt_t month, UInt_t day, UInt_t hour, UInt_t min, UInt_t sec, UInt_t nsec=0, Bool_t isUTC=kTRUE, Int_t secOffset=0)
 
 ValTimeStamp (UInt_t date, UInt_t time, UInt_t nsec, Bool_t isUTC=kTRUE, Int_t secOffset=0)
 
 ValTimeStamp (Double_t seconds)
 
virtual ~ValTimeStamp ()
 
 operator double () const
 
timespec_t GetTimeSpec () const
 Get timestamp as a timespec_t.
 
time_t GetSec (void) const
 Get (integral) seconds after the EPOCH.
 
Int_t GetNanoSec (void) const
 Get nanoseconds after the second.
 
Double_t GetSeconds (void) const
 Get time from the epoch in seconds.
 
const char * AsString (Option_t *option="") const
 
void Copy (ValTimeStamp &vldts) const
 
Int_t GetDate (Bool_t inUTC=kTRUE, Int_t secOffset=0, UInt_t *year=0, UInt_t *month=0, UInt_t *day=0) const
 
Int_t GetTime (Bool_t inUTC=kTRUE, Int_t secOffset=0, UInt_t *hour=0, UInt_t *min=0, UInt_t *sec=0) const
 
void Add (const ValTimeStamp &offset)
 
void Add (Double_t seconds)
 
void Print (Option_t *option="") const
 

Static Public Member Functions

static ValTimeStamp GetBOT ()
 Static method to return the "beginning of time" (start of Unix EPOCH)
 
static ValTimeStamp GetEOT ()
 
static ValTimeStamp GetNBOT ()
 
static Int_t GetZoneOffset ()
 
static time_t MktimeFromUTC (tm_t *tmstruct)
 
static Bool_t IsLeapYear (Int_t year)
 Is the given year a leap year.
 
static void DumpTMStruct (const tm_t &tmstruct)
 Print out the "tm" structure:
 

Private Member Functions

void Set ()
 
void Set (Int_t year, Int_t month, Int_t day, Int_t hour, Int_t min, Int_t sec, Int_t nsec, Bool_t isUTC, Int_t secOffset)
 
void Set (Int_t date, Int_t time, Int_t nsec, Bool_t isUTC, Int_t secOffset)
 
void NormalizeNanoSec ()
 

Private Attributes

Int_t fSec
 
Int_t fNanoSec
 

Friends

Bool_t operator== (const ValTimeStamp &lhs, const ValTimeStamp &rhs)
 
Bool_t operator!= (const ValTimeStamp &lhs, const ValTimeStamp &rhs)
 
Bool_t operator< (const ValTimeStamp &lhs, const ValTimeStamp &rhs)
 
Bool_t operator<= (const ValTimeStamp &lhs, const ValTimeStamp &rhs)
 
Bool_t operator> (const ValTimeStamp &lhs, const ValTimeStamp &rhs)
 
Bool_t operator>= (const ValTimeStamp &lhs, const ValTimeStamp &rhs)
 
ValTimeStamp operator- (const ValTimeStamp &lhs, const ValTimeStamp &rhs)
 

Detailed Description

Definition at line 16 of file ValTimeStamp.h.

View newest version in sPHENIX GitHub at line 16 of file ValTimeStamp.h

Constructor & Destructor Documentation

ValTimeStamp::ValTimeStamp ( )

Empty ctor (builds current time with nsec field filled as best possible)

Definition at line 47 of file ValTimeStamp.cxx.

View newest version in sPHENIX GitHub at line 47 of file ValTimeStamp.cxx

References Set().

Referenced by GetBOT(), GetEOT(), and GetNBOT().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ValTimeStamp::ValTimeStamp ( const ValTimeStamp source)
inline

Copy.

Definition at line 46 of file ValTimeStamp.h.

View newest version in sPHENIX GitHub at line 46 of file ValTimeStamp.h

ValTimeStamp::ValTimeStamp ( const timespec_t &  ts)
inline

Construction from timespec struct.

Definition at line 56 of file ValTimeStamp.h.

View newest version in sPHENIX GitHub at line 56 of file ValTimeStamp.h

ValTimeStamp::ValTimeStamp ( const time_t &  t,
const Int_t  nsec 
)
inline

Construction from time_t and separate nsec.

Definition at line 61 of file ValTimeStamp.h.

View newest version in sPHENIX GitHub at line 61 of file ValTimeStamp.h

ValTimeStamp::ValTimeStamp ( UInt_t  year,
UInt_t  month,
UInt_t  day,
UInt_t  hour,
UInt_t  min,
UInt_t  sec,
UInt_t  nsec = 0,
Bool_t  isUTC = kTRUE,
Int_t  secOffset = 0 
)

Create a ValTimeStamp and set it to the specified year, month, day, time, hour, minute, second and nanosec. If !isUTC then it is assumed to be the standard local time zone.

If local time is PST then one can use

ValTimeStamp(year,month,day,hour,min,sec,nsec,kFALSE,0);

or

Int_t secOffset = 8*60*60; ValTimeStamp(year,month,day,hour,min,sec,nsec,kTRUE,8*60*60);

Definition at line 51 of file ValTimeStamp.cxx.

View newest version in sPHENIX GitHub at line 51 of file ValTimeStamp.cxx

References Set().

+ Here is the call graph for this function:

ValTimeStamp::ValTimeStamp ( UInt_t  date,
UInt_t  time,
UInt_t  nsec,
Bool_t  isUTC = kTRUE,
Int_t  secOffset = 0 
)

Create a ValTimeStamp and set it to the specified date, time, nanosec. If !isUTC then it is assumed to be the standard local time zone.

Definition at line 72 of file ValTimeStamp.cxx.

View newest version in sPHENIX GitHub at line 72 of file ValTimeStamp.cxx

References Set().

+ Here is the call graph for this function:

ValTimeStamp::ValTimeStamp ( Double_t  seconds)
inline

Create a ValTimeStamp using double precision floating point seconds from the EPOCH.

Warning
This will truncate precision to no better than about 1 microsecond. Do not use this constructor for timestamps that are expected to be more precise!

Definition at line 95 of file ValTimeStamp.h.

View newest version in sPHENIX GitHub at line 95 of file ValTimeStamp.h

ValTimeStamp::~ValTimeStamp ( )
virtual

Definition at line 48 of file ValTimeStamp.cxx.

View newest version in sPHENIX GitHub at line 48 of file ValTimeStamp.cxx

Member Function Documentation

void ValTimeStamp::Add ( const ValTimeStamp offset)

Definition at line 248 of file ValTimeStamp.cxx.

View newest version in sPHENIX GitHub at line 248 of file ValTimeStamp.cxx

References fNanoSec, fSec, and NormalizeNanoSec().

+ Here is the call graph for this function:

void ValTimeStamp::Add ( Double_t  seconds)

Definition at line 258 of file ValTimeStamp.cxx.

View newest version in sPHENIX GitHub at line 258 of file ValTimeStamp.cxx

References fNanoSec, fSec, and NormalizeNanoSec().

+ Here is the call graph for this function:

const char * ValTimeStamp::AsString ( Option_t *  option = "") const

Return the date & time as a string.

Result is pointer to a statically allocated string. User should copy this into their own buffer before calling this method again. This is somewhat mitigated by use of a circular buffer of strings.

Option "l" returns it in local zone format (can be applied to default or compact format).

Default format is RFC822 compliant: "Mon, 02 Jan 2001 18:11:12 +0000 (GMT) +999999999 nsec" "Mon, 02 Jan 2001 10:11:12 -0800 (PST) +999999999 nsec"

Option "c" compact is (almost) ISO 8601 compliant: "2001-01-02 18:11:12.9999999999Z" "2001-01-02 10:11:12.9999999999-0800" if PST

  • uses "-" as date separator as specified in ISO 8601
  • uses "." rather than preferred "," for decimal separator
  • -HHMM is the difference between local and UTC (if behind, + if ahead). The "-HHMM" is replaced with "Z" if given as UTC. To be strictly conforming it should use "T" instead of the blank separating the date and time.

Option "2" returns as {sec,nsec} integers.

Option "s" returns "2001-01-02 18:11:12" with an implied UTC, overrides "l" option.

Internally uses a circular list of buffers to avoid problems using AsString multiple times in a single statement.

Definition at line 83 of file ValTimeStamp.cxx.

View newest version in sPHENIX GitHub at line 83 of file ValTimeStamp.cxx

References fNanoSec, and fSec.

Referenced by ValContext::AsString(), FairDbResultKey::AsString(), ValRange::AsString(), ValValidate::CompareTimeStamps(), FairDbSqlContext::FairDbSqlContext(), FairDbValidityRec::GetL2CacheName(), FairDb::MakeDateTimeString(), operator<<(), Print(), FairDbProxy::ReplaceInsertDate(), FairDbSqlValPacket::SetCreationDate(), and ValValidate::TestTimeStamp().

+ Here is the caller graph for this function:

void ValTimeStamp::Copy ( ValTimeStamp vldts) const

Definition at line 180 of file ValTimeStamp.cxx.

View newest version in sPHENIX GitHub at line 180 of file ValTimeStamp.cxx

References fNanoSec, and fSec.

void ValTimeStamp::DumpTMStruct ( const tm_t &  tmstruct)
static

Print out the "tm" structure:

Definition at line 532 of file ValTimeStamp.cxx.

View newest version in sPHENIX GitHub at line 532 of file ValTimeStamp.cxx

References printf().

+ Here is the call graph for this function:

ValTimeStamp ValTimeStamp::GetBOT ( )
static

Static method to return the "beginning of time" (start of Unix EPOCH)

Definition at line 26 of file ValTimeStamp.cxx.

View newest version in sPHENIX GitHub at line 26 of file ValTimeStamp.cxx

References ValTimeStamp().

+ Here is the call graph for this function:

Int_t ValTimeStamp::GetDate ( Bool_t  inUTC = kTRUE,
Int_t  secOffset = 0,
UInt_t *  year = 0,
UInt_t *  month = 0,
UInt_t *  day = 0 
) const

Return date in form of 19971224 (i.e. 24/12/1997), if non-zero pointers supplied for year, month, day fill those as well

Definition at line 190 of file ValTimeStamp.cxx.

View newest version in sPHENIX GitHub at line 190 of file ValTimeStamp.cxx

References fSec.

Referenced by FairDb::MakeTimeStamp(), and ValValidate::TestTimeStamp().

+ Here is the caller graph for this function:

ValTimeStamp ValTimeStamp::GetEOT ( )
static

Static method to return the "end of time" which is sometime in the future and near or at the limit of ValTimeStamp's ability to hold large times.

Definition at line 31 of file ValTimeStamp.cxx.

View newest version in sPHENIX GitHub at line 31 of file ValTimeStamp.cxx

References ValTimeStamp().

+ Here is the call graph for this function:

Int_t ValTimeStamp::GetNanoSec ( void  ) const
inline

Get nanoseconds after the second.

Definition at line 119 of file ValTimeStamp.h.

View newest version in sPHENIX GitHub at line 119 of file ValTimeStamp.h

Referenced by operator-().

+ Here is the caller graph for this function:

ValTimeStamp ValTimeStamp::GetNBOT ( )
static

Static method to return the "negative beginning of time", i.e. the earliest time prior to start of Unix EPOCH which is negative seconds.

Definition at line 36 of file ValTimeStamp.cxx.

View newest version in sPHENIX GitHub at line 36 of file ValTimeStamp.cxx

References ValTimeStamp().

+ Here is the call graph for this function:

time_t ValTimeStamp::GetSec ( void  ) const
inline

Get (integral) seconds after the EPOCH.

Definition at line 117 of file ValTimeStamp.h.

View newest version in sPHENIX GitHub at line 117 of file ValTimeStamp.h

Referenced by ClassImp(), FairDbProxy::FindTimeBoundaries(), FairDbValidityRecBuilder::MakeGapRec(), operator-(), FairDbTableProxy::QueryOverlayCreationDate(), and FairDbProxy::QueryValidity().

+ Here is the caller graph for this function:

Double_t ValTimeStamp::GetSeconds ( void  ) const
inline

Get time from the epoch in seconds.

Definition at line 122 of file ValTimeStamp.h.

View newest version in sPHENIX GitHub at line 122 of file ValTimeStamp.h

Int_t ValTimeStamp::GetTime ( Bool_t  inUTC = kTRUE,
Int_t  secOffset = 0,
UInt_t *  hour = 0,
UInt_t *  min = 0,
UInt_t *  sec = 0 
) const

Return time in form of 123623 (i.e. 12:36:23), if non-zero pointers supplied for hour, min, sec fill those as well

Definition at line 208 of file ValTimeStamp.cxx.

View newest version in sPHENIX GitHub at line 208 of file ValTimeStamp.cxx

References fSec.

Referenced by ValValidate::TestTimeStamp().

+ Here is the caller graph for this function:

timespec_t ValTimeStamp::GetTimeSpec ( ) const
inline

Get timestamp as a timespec_t.

Definition at line 113 of file ValTimeStamp.h.

View newest version in sPHENIX GitHub at line 113 of file ValTimeStamp.h

References value.

Referenced by ValValidate::TestTimeStamp().

+ Here is the caller graph for this function:

Int_t ValTimeStamp::GetZoneOffset ( )
static

Static method returning local (current) time zone offset from UTC. This is the difference in seconds between UTC and local standard time.

Definition at line 226 of file ValTimeStamp.cxx.

View newest version in sPHENIX GitHub at line 226 of file ValTimeStamp.cxx

References Acts::Test::time.

Referenced by ValValidate::TestTimeStamp().

+ Here is the caller graph for this function:

Bool_t ValTimeStamp::IsLeapYear ( Int_t  year)
static

Is the given year a leap year.

Definition at line 501 of file ValTimeStamp.cxx.

View newest version in sPHENIX GitHub at line 501 of file ValTimeStamp.cxx

Referenced by MktimeFromUTC().

+ Here is the caller graph for this function:

time_t ValTimeStamp::MktimeFromUTC ( tm_t *  tmstruct)
static

Equivalent of standard routine "mktime" but using the assumption that tm struct is filled with UTC, not local, time.

This version ISN'T configured to handle every possible weirdness of out-of-range values in the case of normalizing the tm struct.

This version DOESN'T correctly handle values that can't be fit into a time_t (i.e. beyond year 2038-01-18 19:14:07, or before the start of Epoch).

Definition at line 443 of file ValTimeStamp.cxx.

View newest version in sPHENIX GitHub at line 443 of file ValTimeStamp.cxx

References IsLeapYear().

Referenced by Set().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ValTimeStamp::NormalizeNanoSec ( )
private

Definition at line 427 of file ValTimeStamp.cxx.

View newest version in sPHENIX GitHub at line 427 of file ValTimeStamp.cxx

References fNanoSec, and fSec.

Referenced by Add(), and Set().

+ Here is the caller graph for this function:

ValTimeStamp::operator double ( ) const
inline

Implicitly convert a ValTimeStamp to a double.

Warning
This will truncate precision to no better than about 1 microsecond. Do not compare/subtract ValTimeStamps that have been converted to doubles if you require the full nanosecond precision!

Definition at line 109 of file ValTimeStamp.h.

View newest version in sPHENIX GitHub at line 109 of file ValTimeStamp.h

ValTimeStamp& ValTimeStamp::operator= ( const ValTimeStamp source)
inline

Assignment.

Definition at line 50 of file ValTimeStamp.h.

View newest version in sPHENIX GitHub at line 50 of file ValTimeStamp.h

References fNanoSec, and fSec.

void ValTimeStamp::Print ( Option_t *  option = "") const

Definition at line 273 of file ValTimeStamp.cxx.

View newest version in sPHENIX GitHub at line 273 of file ValTimeStamp.cxx

References AsString(), and printf().

Referenced by ValValidate::TestTimeStamp().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ValTimeStamp::Set ( )
private

Definition at line 282 of file ValTimeStamp.cxx.

View newest version in sPHENIX GitHub at line 282 of file ValTimeStamp.cxx

References fNanoSec, fSec, and Acts::Test::time.

Referenced by Set(), and ValTimeStamp().

+ Here is the caller graph for this function:

void ValTimeStamp::Set ( Int_t  year,
Int_t  month,
Int_t  day,
Int_t  hour,
Int_t  min,
Int_t  sec,
Int_t  nsec,
Bool_t  isUTC,
Int_t  secOffset 
)
private

Definition at line 331 of file ValTimeStamp.cxx.

View newest version in sPHENIX GitHub at line 331 of file ValTimeStamp.cxx

References fNanoSec, fSec, min, MktimeFromUTC(), and NormalizeNanoSec().

+ Here is the call graph for this function:

void ValTimeStamp::Set ( Int_t  date,
Int_t  time,
Int_t  nsec,
Bool_t  isUTC,
Int_t  secOffset 
)
private

Definition at line 386 of file ValTimeStamp.cxx.

View newest version in sPHENIX GitHub at line 386 of file ValTimeStamp.cxx

References min, and Set().

+ Here is the call graph for this function:

Friends And Related Function Documentation

Bool_t operator!= ( const ValTimeStamp lhs,
const ValTimeStamp rhs 
)
friend

Definition at line 226 of file ValTimeStamp.h.

View newest version in sPHENIX GitHub at line 226 of file ValTimeStamp.h

ValTimeStamp operator- ( const ValTimeStamp lhs,
const ValTimeStamp rhs 
)
friend

Definition at line 260 of file ValTimeStamp.h.

View newest version in sPHENIX GitHub at line 260 of file ValTimeStamp.h

Bool_t operator< ( const ValTimeStamp lhs,
const ValTimeStamp rhs 
)
friend

Definition at line 232 of file ValTimeStamp.h.

View newest version in sPHENIX GitHub at line 232 of file ValTimeStamp.h

Bool_t operator<= ( const ValTimeStamp lhs,
const ValTimeStamp rhs 
)
friend

Definition at line 239 of file ValTimeStamp.h.

View newest version in sPHENIX GitHub at line 239 of file ValTimeStamp.h

Bool_t operator== ( const ValTimeStamp lhs,
const ValTimeStamp rhs 
)
friend

Definition at line 220 of file ValTimeStamp.h.

View newest version in sPHENIX GitHub at line 220 of file ValTimeStamp.h

Bool_t operator> ( const ValTimeStamp lhs,
const ValTimeStamp rhs 
)
friend

Definition at line 246 of file ValTimeStamp.h.

View newest version in sPHENIX GitHub at line 246 of file ValTimeStamp.h

Bool_t operator>= ( const ValTimeStamp lhs,
const ValTimeStamp rhs 
)
friend

Definition at line 253 of file ValTimeStamp.h.

View newest version in sPHENIX GitHub at line 253 of file ValTimeStamp.h

Member Data Documentation

Int_t ValTimeStamp::fNanoSec
private

Definition at line 213 of file ValTimeStamp.h.

View newest version in sPHENIX GitHub at line 213 of file ValTimeStamp.h

Referenced by Add(), AsString(), Copy(), NormalizeNanoSec(), operator!=(), operator<(), operator<=(), operator=(), operator==(), operator>(), operator>=(), and Set().

Int_t ValTimeStamp::fSec
private

Definition at line 212 of file ValTimeStamp.h.

View newest version in sPHENIX GitHub at line 212 of file ValTimeStamp.h

Referenced by Add(), AsString(), Copy(), GetDate(), GetTime(), NormalizeNanoSec(), operator!=(), operator<(), operator<=(), operator=(), operator==(), operator>(), operator>=(), and Set().


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