ROOT
6.07/01
Reference Guide
|
The TTimeStamp encapsulates seconds and ns since EPOCH.
This extends (and isolates) struct timespec
No accounting of leap seconds is made.
Due to ROOT/CINT limitations TTimeStamp does not explicitly hold a timespec struct; attempting to do so means the Streamer must be hand written. Instead we have chosen to simply contain similar fields within the private area of this class.
NOTE: the use of time_t (and its default implementation as a 32 int) implies overflow conditions occurs somewhere around Jan 18, 19:14:07, 2038
. If this experiment is still going when it becomes significant someone will have to deal with it.
Definition at line 76 of file TTimeStamp.h.
Public Member Functions | |
TTimeStamp () | |
Default ctor. More... | |
TTimeStamp (const timespec_t &ts) | |
TTimeStamp (time_t t, Int_t nsec) | |
TTimeStamp (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 TTimeStamp and set it to the specified year, month, day, time, hour, minute, second and nanosec. More... | |
TTimeStamp (UInt_t date, UInt_t time, UInt_t nsec, Bool_t isUTC=kTRUE, Int_t secOffset=0) | |
Create a TTimeStamp and set it to the specified date, time, nanosec. More... | |
TTimeStamp (UInt_t tloc, Bool_t isUTC=kTRUE, Int_t secOffset=0, Bool_t dosDate=kFALSE) | |
Create a TTimeStamp and set it to tloc which must be a time_t value returned by time(). More... | |
virtual | ~TTimeStamp () |
void | Set () |
Set Date/Time to current time as reported by the system. More... | |
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) |
Set Date/Time from components. More... | |
void | Set (Int_t date, Int_t time, Int_t nsec, Bool_t isUTC, Int_t secOffset) |
Set date/time from integers of the form [yy]YYMMDD and HHMMSS, assume UTC (UTC) components: More... | |
void | Set (UInt_t tloc, Bool_t isUTC, Int_t secOffset, Bool_t dosDate) |
The input arg is a time_t value returned by time() or a value returned by Convert(). More... | |
void | SetSec (Int_t sec) |
void | SetNanoSec (Int_t nsec) |
timespec_t | GetTimeSpec () const |
time_t | GetSec () const |
Int_t | GetNanoSec () const |
Double_t | AsDouble () const |
Double_t | AsJulianDate () const |
Double_t | AsGMST (Double_t UT1Offset=0) const |
Return Greenwich mean sidereal time (GMST) in hour-angle. More... | |
Double_t | AsGAST (Double_t UT1Offset=0) const |
Return Greenwich apparent sidereal time (GAST) in hour-angle. More... | |
Double_t | AsLMST (Double_t Longitude, Double_t UT1Offset=0) const |
Return local mean sidereal time (LMST) in hour-angle, given a longitude in degrees. More... | |
Double_t | AsLAST (Double_t Longitude, Double_t UT1Offset=0) const |
Return local apparent sidereal time (LAST) in hour-angle, given a longitude in degrees. More... | |
const char * | AsString (const Option_t *option="") const |
Return the date & time as a string. More... | |
void | Copy (TTimeStamp &ts) const |
Copy this to ts. More... | |
UInt_t | 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. More... | |
UInt_t | 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. More... | |
Int_t | GetDayOfYear (Bool_t inUTC=kTRUE, Int_t secOffset=0) const |
Get the day of the year represented by this time stamp value. More... | |
Int_t | GetDayOfWeek (Bool_t inUTC=kTRUE, Int_t secOffset=0) const |
Method is using Zeller's formula for calculating the day number. More... | |
Int_t | GetMonth (Bool_t inUTC=kTRUE, Int_t secOffset=0) const |
Get the month of the year. Valid return values are between 1 and 12. More... | |
Int_t | GetWeek (Bool_t inUTC=kTRUE, Int_t secOffset=0) const |
Get the week of the year. More... | |
Bool_t | IsLeapYear (Bool_t inUTC=kTRUE, Int_t secOffset=0) const |
Is the year a leap year. More... | |
void | Add (const TTimeStamp &offset) |
Add "offset" as a delta time. More... | |
void | Print (const Option_t *option="") const |
Print date and time. More... | |
operator double () const | |
Static Public Member Functions | |
static Int_t | GetZoneOffset () |
Static method returning local (current) time zone offset from UTC. More... | |
static time_t | MktimeFromUTC (tm_t *tmstruct) |
Equivalent of standard routine "mktime" but using the assumption that tm struct is filled with UTC, not local, time. More... | |
static void | DumpTMStruct (const tm_t &tmstruct) |
Print out the "tm" structure:
tmstruct.tm_year = year; // years since 1900
tmstruct.tm_mon = month-1; // months since Jan [0,11]
tmstruct.tm_mday = day; // day of the month [1,31]
tmstruct.tm_hour = hour; // hours since midnight [0,23]
tmstruct.tm_min = min; // minutes after the hour [0,59]
tmstruct.tm_sec = sec; // seconds after the minute [0,59]
tmstruct.tm_wday // day of week [0,6]
tmstruct.tm_yday // days in year [0,365]
tmstruct.tm_isdst // DST [-1/0/1] (unknown,false,true)
. More... | |
static Int_t | GetDayOfYear (Int_t day, Int_t month, Int_t year) |
Get the day of the year represented by day, month and year. More... | |
static Int_t | GetDayOfWeek (Int_t day, Int_t month, Int_t year) |
Method is using Zeller's formula for calculating the day number. More... | |
static Int_t | GetWeek (Int_t day, Int_t month, Int_t year) |
Get the week of the year. More... | |
static Bool_t | IsLeapYear (Int_t year) |
Is the given year a leap year. More... | |
Private Member Functions | |
void | NormalizeNanoSec () |
Ensure that the fNanoSec field is in range [0,999999999]. More... | |
Private Attributes | |
Int_t | fSec |
Int_t | fNanoSec |
Friends | |
Bool_t | operator== (const TTimeStamp &lhs, const TTimeStamp &rhs) |
Bool_t | operator!= (const TTimeStamp &lhs, const TTimeStamp &rhs) |
Bool_t | operator< (const TTimeStamp &lhs, const TTimeStamp &rhs) |
Bool_t | operator<= (const TTimeStamp &lhs, const TTimeStamp &rhs) |
Bool_t | operator> (const TTimeStamp &lhs, const TTimeStamp &rhs) |
Bool_t | operator>= (const TTimeStamp &lhs, const TTimeStamp &rhs) |
#include <TTimeStamp.h>
TTimeStamp::TTimeStamp | ( | ) |
Default ctor.
Create a TTimeStamp and set it to the current time (as best possible). The nanosecond part is faked so that subsequent calls simply add 1 to ensure that sequential calls are distinct (and sortable).
Definition at line 94 of file TTimeStamp.cxx.
|
inline |
Definition at line 96 of file TTimeStamp.h.
|
inline |
Definition at line 100 of file TTimeStamp.h.
TTimeStamp::TTimeStamp | ( | 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 TTimeStamp 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
or
Definition at line 114 of file TTimeStamp.cxx.
TTimeStamp::TTimeStamp | ( | UInt_t | date, |
UInt_t | time, | ||
UInt_t | nsec, | ||
Bool_t | isUTC = kTRUE , |
||
Int_t | secOffset = 0 |
||
) |
Create a TTimeStamp and set it to the specified date, time, nanosec.
If !isUTC then it is assumed to be the standard local time zone.
TTimeStamp(UInt_t tloc, Bool_t isUTC, Int_t secOffset, Bool_t dosDate)
instead of this one. Your best bet is to explicitly pass UInt_t values instead of Int_t values. When calling with integer literals, pass for instance Definition at line 136 of file TTimeStamp.cxx.
TTimeStamp::TTimeStamp | ( | UInt_t | tloc, |
Bool_t | isUTC = kTRUE , |
||
Int_t | secOffset = 0 , |
||
Bool_t | dosDate = kFALSE |
||
) |
Create a TTimeStamp and set it to tloc which must be a time_t value returned by time().
This value is the number of seconds since the EPOCH (i.e. 00:00:00 on Jan 1m 1970). If dosDate is true then the input is a dosDate value.
Definition at line 149 of file TTimeStamp.cxx.
|
inlinevirtual |
Definition at line 117 of file TTimeStamp.h.
void TTimeStamp::Add | ( | const TTimeStamp & | offset | ) |
Add "offset" as a delta time.
Definition at line 532 of file TTimeStamp.cxx.
|
inline |
Definition at line 143 of file TTimeStamp.h.
Referenced by Memstat::TMemStatMng::AddPointer(), AsJulianDate(), Memstat::TMemStatMng::Init(), and operator double().
Return Greenwich apparent sidereal time (GAST) in hour-angle.
Return value will always be between 0 and 24 (hours). Sidereal time is most accurately calculated from UT1. If fSec and fNanoSec are in UTC (which they are by default), the optional argument UT1Offset can be supplied (in milliseconds). If UT1Offset is not supplied, conversion has maximum error of 1s. If offset is supplied error can be reduced to us level. Values for UT1Offset can be found in IERS Bulletin B: ftp://ftp.iers.org/products/eop/bulletinb/format_2009/ Equation of the equinoxes is given by USNO: http://aa.usno.navy.mil/faq/docs/GAST.php
Definition at line 190 of file TTimeStamp.cxx.
Referenced by AsLAST().
Return Greenwich mean sidereal time (GMST) in hour-angle.
Return value will always be between 0 and 24 (hours). Sidereal time is most accurately calculated from UT1. If fSec and fNanoSec are in UTC (which they are by default), the optional argument UT1Offset can be supplied (in milliseconds). If UT1Offset is not supplied, conversion has maximum error of 1s. If offset is supplied error can be reduced to us level. Values for UT1Offset can be found in IERS Bulletin B: ftp://ftp.iers.org/products/eop/bulletinb/format_2009/ The conversion to sidereal time used here is given by Aoki et. al. Astron. Astrophys. 105, 359-362 (1982) http://adsabs.harvard.edu/abs/1982A%26A...105..359A
Definition at line 167 of file TTimeStamp.cxx.
|
inline |
Definition at line 144 of file TTimeStamp.h.
Return local apparent sidereal time (LAST) in hour-angle, given a longitude in degrees.
Return value will always be between 0 and 24 (hours). Sidereal time is most accurately calculated from UT1. If fSec and fNanoSec are in UTC (which they are by default), the optional argument UT1Offset can be supplied (in milliseconds). If UT1Offset is not supplied, conversion has maximum error of 1s. If offset is supplied error can be reduced to us level. Values for UT1Offset can be found in IERS Bulletin B: ftp://ftp.iers.org/products/eop/bulletinb/format_2009/
Definition at line 228 of file TTimeStamp.cxx.
Return local mean sidereal time (LMST) in hour-angle, given a longitude in degrees.
Return value will always be between 0 and 24 (hours). Sidereal time is most accurately calculated from UT1. If fSec and fNanoSec are in UTC (which they are by default), the optional argument UT1Offset can be supplied (in milliseconds). If UT1Offset is not supplied, conversion has maximum error of 1s. If offset is supplied error can be reduced to us level. Values for UT1Offset can be found in IERS Bulletin B: ftp://ftp.iers.org/products/eop/bulletinb/format_2009/
Definition at line 212 of file TTimeStamp.cxx.
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.
Option "l" returns it in local zone format (can be applied to default or compact format).
Default format is RFC822 compliant:
Option "c" compact is (almost) ISO 8601 compliant:
"2001-01-02 10:11:12.9999999999-0800" if PST
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 269 of file TTimeStamp.cxx.
Referenced by TProofServ::ErrorHandler(), TProofBench::GetPerfSpecs(), operator<<(), TPerfStats::PacketEvent(), Print(), and TPerfStats::WriteQueryLog().
void TTimeStamp::Copy | ( | TTimeStamp & | ts | ) | const |
Copy this to ts.
Definition at line 341 of file TTimeStamp.cxx.
Print out the "tm" structure:
.
Definition at line 901 of file TTimeStamp.cxx.
UInt_t TTimeStamp::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 351 of file TTimeStamp.cxx.
Referenced by RooStats::HistFactory::Channel::PrintXML(), and RooStats::HistFactory::Measurement::PrintXML().
Method is using Zeller's formula for calculating the day number.
Valid return values range between 1 and 7, where Monday = 1.
Definition at line 416 of file TTimeStamp.cxx.
Referenced by GetWeek().
Method is using Zeller's formula for calculating the day number.
Valid return values range between 1 and 7, where Monday = 1.
Definition at line 827 of file TTimeStamp.cxx.
Get the day of the year represented by this time stamp value.
Valid return values range between 1 and 366, where January 1 = 1.
Definition at line 395 of file TTimeStamp.cxx.
Referenced by GetWeek().
Get the day of the year represented by day, month and year.
Valid return values range between 1 and 366, where January 1 = 1.
Definition at line 810 of file TTimeStamp.cxx.
Get the month of the year. Valid return values are between 1 and 12.
Definition at line 436 of file TTimeStamp.cxx.
|
inline |
Definition at line 141 of file TTimeStamp.h.
Referenced by TProofPerfAnalysis::FillFileInfo(), TProofPerfAnalysis::FillWrkInfo(), TMonitor::GetActive(), TThread::GetTime(), TShutdownTimer::Notify(), and TWin32Condition::TimedWait().
|
inline |
Definition at line 140 of file TTimeStamp.h.
Referenced by TProofPerfAnalysis::FillFileInfo(), TProofPerfAnalysis::FillWrkInfo(), TMonitor::GetActive(), TThread::GetTime(), TShutdownTimer::Notify(), TPerfStats::PacketEvent(), TMultiLayerPerceptron::Randomize(), TProofServLite::Setup(), TProofServ::Setup(), TMultiLayerPerceptron::Shuffle(), TWin32Condition::TimedWait(), and TPerfStats::WriteQueryLog().
UInt_t TTimeStamp::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 373 of file TTimeStamp.cxx.
|
inline |
Definition at line 138 of file TTimeStamp.h.
Get the week of the year.
Valid week values are between 1 and 53. The return value is the year*100+week (1 Jan may be in the last week of the previous year so the year must be returned too).
Definition at line 454 of file TTimeStamp.cxx.
Get the week of the year.
Valid week values are between 1 and 53. The return value is the year*100+week (1 Jan may be in the last week of the previous year so the year must be returned too).
Definition at line 848 of file TTimeStamp.cxx.
|
static |
Static method returning local (current) time zone offset from UTC.
This is the value in seconds one must add to the local time to arrive at Coordinated Universal Time, so it is negative east of the Prime Meridian.
Definition at line 502 of file TTimeStamp.cxx.
Is the year a leap year.
The calendar year is 365 days long, unless the year is exactly divisible by 4, in which case an extra day is added to February to make the year 366 days long. If the year is the last year of a century, eg. 1700, 1800, 1900, 2000, then it is only a leap year if it is exactly divisible by
Definition at line 482 of file TTimeStamp.cxx.
Referenced by GetDayOfYear(), and MktimeFromUTC().
Is the given year a leap year.
The calendar year is 365 days long, unless the year is exactly divisible by 4, in which case an extra day is added to February to make the year 366 days long. If the year is the last year of a century, eg. 1700, 1800, 1900, 2000, then it is only a leap year if it is exactly divisible by
Definition at line 882 of file TTimeStamp.cxx.
|
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 765 of file TTimeStamp.cxx.
Referenced by Set().
|
private |
Ensure that the fNanoSec field is in range [0,999999999].
Definition at line 737 of file TTimeStamp.cxx.
Referenced by Add(), Set(), and TTimeStamp().
|
inline |
Definition at line 171 of file TTimeStamp.h.
Print date and time.
Definition at line 542 of file TTimeStamp.cxx.
void TTimeStamp::Set | ( | ) |
Set Date/Time to current time as reported by the system.
No accounting for nanoseconds with std ANSI functions, ns part faked so that subsequent calls simply add 1 to it this ensures that calls within the same second come back distinct (and sortable). Time is since Jan 1, 1970.
Definition at line 554 of file TTimeStamp.cxx.
Referenced by Memstat::TMemStatMng::AddPointer(), Set(), TUDPSocket::Touch(), TSocket::Touch(), and TTimeStamp().
void TTimeStamp::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 | ||
) |
Set Date/Time from components.
Month & day both use normal 1..12 and 1..31 counting, hours, min, sec run from 0 to 23, 59, 59 respectively, secOffset provides method for adjusting for alternative timezones
Definition at line 605 of file TTimeStamp.cxx.
Set date/time from integers of the form [yy]YYMMDD and HHMMSS, assume UTC (UTC) components:
Definition at line 658 of file TTimeStamp.cxx.
The input arg is a time_t value returned by time() or a value returned by Convert().
This value is the number of seconds since the EPOCH (i.e. 00:00:00 on Jan 1m 1970). If dosDate is true then the input is a dosDate value.
Definition at line 688 of file TTimeStamp.cxx.
Definition at line 136 of file TTimeStamp.h.
Definition at line 135 of file TTimeStamp.h.
|
friend |
Definition at line 190 of file TTimeStamp.h.
|
friend |
Definition at line 194 of file TTimeStamp.h.
|
friend |
Definition at line 199 of file TTimeStamp.h.
|
friend |
Definition at line 186 of file TTimeStamp.h.
|
friend |
Definition at line 204 of file TTimeStamp.h.
|
friend |
Definition at line 209 of file TTimeStamp.h.
|
private |
Definition at line 87 of file TTimeStamp.h.
Referenced by Add(), AsDouble(), AsString(), Copy(), GetNanoSec(), GetTimeSpec(), NormalizeNanoSec(), operator!=(), operator<(), operator<=(), operator==(), operator>(), operator>=(), Set(), and SetNanoSec().
|
private |
Definition at line 86 of file TTimeStamp.h.
Referenced by Add(), AsDouble(), AsString(), Copy(), GetDate(), GetDayOfWeek(), GetDayOfYear(), GetMonth(), GetSec(), GetTime(), GetTimeSpec(), GetWeek(), IsLeapYear(), NormalizeNanoSec(), operator!=(), operator<(), operator<=(), operator==(), operator>(), operator>=(), Set(), and SetSec().