VldTimeStamp Class Reference
[Validity]

Encapsulate the seconds and ns since EPOCH. More...

#include <VldTimeStamp.h>

List of all members.

Public Member Functions

 VldTimeStamp ()
 Empty ctor (builds current time with nsec field filled as best possible).
 VldTimeStamp (const VldTimeStamp &source)
 Copy.
VldTimeStampoperator= (const VldTimeStamp &source)
 Assignment.
 VldTimeStamp (const timespec_t &ts)
 Construction from timespec struct.
 VldTimeStamp (const time_t &t, const Int_t nsec)
 Construction from time_t and separate nsec.
 VldTimeStamp (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)
 VldTimeStamp (UInt_t date, UInt_t time, UInt_t nsec, Bool_t isUTC=kTRUE, Int_t secOffset=0)
 VldTimeStamp (Double_t seconds)
virtual ~VldTimeStamp ()
 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 (VldTimeStamp &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 VldTimeStamp &offset)
void Add (Double_t seconds)
void Print (Option_t *option="") const

Static Public Member Functions

static VldTimeStamp GetBOT ()
 Static method to return the "beginning of time" (start of Unix EPOCH).
static VldTimeStamp GetEOT ()
static VldTimeStamp 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 VldTimeStamp &lhs, const VldTimeStamp &rhs)
Bool_t operator!= (const VldTimeStamp &lhs, const VldTimeStamp &rhs)
Bool_t operator< (const VldTimeStamp &lhs, const VldTimeStamp &rhs)
Bool_t operator<= (const VldTimeStamp &lhs, const VldTimeStamp &rhs)
Bool_t operator> (const VldTimeStamp &lhs, const VldTimeStamp &rhs)
Bool_t operator>= (const VldTimeStamp &lhs, const VldTimeStamp &rhs)
VldTimeStamp operator- (const VldTimeStamp &lhs, const VldTimeStamp &rhs)

Detailed Description

Encapsulate the seconds and ns since EPOCH.

This extends (and isolates) struct timespec

struct timespec { time_t tv_sec; // seconds long tv_nsec; // nanoseconds } time_t seconds is relative to Jan 1, 1970 00:00:00 UTC

Due to ROOT/CINT limitations VldTimeStamp 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.
Author:
(last to touch it)
Author
rhatcher
Version:
Revision
1.30
Date:
Date
2011/10/31 19:00:59

Contact: R. Hatcher

Created on: Wed Apr 13 17:53:23 2005

Author: R. Hatcher 2000.04.19 R. Hatcher 2000.12.20 -- convert from TDatime to struct timespec

Id
VldTimeStamp.h,v 1.30 2011/10/31 19:00:59 rhatcher Exp

Definition at line 62 of file VldTimeStamp.h.


Constructor & Destructor Documentation

VldTimeStamp::VldTimeStamp (  ) 

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

Definition at line 84 of file VldTimeStamp.cxx.

References Set().

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

00084 : fSec(0), fNanoSec(0) { Set(); }

VldTimeStamp::VldTimeStamp ( const VldTimeStamp source  )  [inline]

Copy.

Definition at line 91 of file VldTimeStamp.h.

00092      : fSec(source.fSec), fNanoSec(source.fNanoSec) { }

VldTimeStamp::VldTimeStamp ( const timespec_t ts  )  [inline]

Construction from timespec struct.

Definition at line 100 of file VldTimeStamp.h.

References NormalizeNanoSec().

00101      : fSec(ts.tv_sec), fNanoSec(ts.tv_nsec)
00102       { NormalizeNanoSec(); }

VldTimeStamp::VldTimeStamp ( const time_t &  t,
const Int_t  nsec 
) [inline]

Construction from time_t and separate nsec.

Definition at line 105 of file VldTimeStamp.h.

References NormalizeNanoSec().

00106      : fSec(t), fNanoSec(nsec)
00107       { NormalizeNanoSec(); }

VldTimeStamp::VldTimeStamp ( 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 VldTimeStamp 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

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

or

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

Definition at line 88 of file VldTimeStamp.cxx.

References Set().

00093   : fSec(0), fNanoSec(0)
00094 {
00095    // Create a VldTimeStamp and set it to the specified year, month,
00096    // day, time, hour, minute, second and nanosec.
00097    // If !isUTC then it is assumed to be the standard local time zone.
00098    //
00099    // If local time is PST then one can use
00100    //    VldTimeStamp(year,month,day,hour,min,sec,nsec,kFALSE,0);
00101    // or
00102    //    Int_t secOffset = 8*60*60;
00103    //    VldTimeStamp(year,month,day,hour,min,sec,nsec,kTRUE,8*60*60);
00104    
00105    Set(year, month, day, hour, min, sec, nsec, isUTC, secOffset);
00106 }

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

Create a VldTimeStamp 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 109 of file VldTimeStamp.cxx.

References Set().

00111   : fSec(0), fNanoSec(0)
00112 {
00113    // Create a VldTimeStamp and set it to the specified date, time, nanosec.
00114    // If !isUTC then it is assumed to be the standard local time zone.
00115 
00116    Set(date, time, nsec, isUTC, secOffset);
00117 }

VldTimeStamp::VldTimeStamp ( Double_t  seconds  )  [inline]

Create a VldTimeStamp 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 139 of file VldTimeStamp.h.

References NormalizeNanoSec().

00140      : fSec((Int_t)seconds), fNanoSec((Int_t)((seconds-fSec)*1.0e9))
00141      { NormalizeNanoSec(); }

VldTimeStamp::~VldTimeStamp (  )  [virtual]

Definition at line 85 of file VldTimeStamp.cxx.

00085 { ; }


Member Function Documentation

void VldTimeStamp::Add ( Double_t  seconds  ) 

Definition at line 295 of file VldTimeStamp.cxx.

References fNanoSec, fSec, Msg::kWarning, MSG, and NormalizeNanoSec().

00296 {
00297   // Add 'seconds' as a delta time
00298 
00299   fSec += (Int_t) seconds;
00300   fNanoSec += (Int_t) (fmod(seconds,1.0) * 1e9);
00301   NormalizeNanoSec();
00302   if(seconds > 1e6) {
00303     MSG("Vld",Msg::kWarning) << "VldTimeStamp moved by offset " 
00304                              << seconds 
00305                              << " which is too large to maintain ns accuracy." 
00306                              << endl;
00307   }
00308 }

void VldTimeStamp::Add ( const VldTimeStamp offset  ) 

Definition at line 285 of file VldTimeStamp.cxx.

References fNanoSec, fSec, and NormalizeNanoSec().

Referenced by PerInputStream::AdvanceWindowTags(), RunSummary::Ana(), RateSummary::Ana(), FarmListModule::Ana(), RerootExodus::BuildVldContext(), SpillTimeFinder::DataIsAvailable(), PulserDBModule::DoWriteGC(), PulserDBModule::DriftPoint(), HvStatusFinder::ExtendedQuery(), CoilTools::ExtendedQuery(), CountPot::FillMBPOT(), SpillTimeFinder::FindClosestEntries(), HepevtModule::FindOrCreateSimSnarlRecord(), CustomLightInjector::Get(), MCMerge::Get(), ToyMCModule::Get(), PhotonInjector::Get(), LightInjector::Get(), FileGap::GetFileBounds(), SpillTimeFinder::GetNearestSpill(), GenieModule::GetNextVldContext(), SpillTimeFinder::GetTimeOfNearestSpill(), SpillTimeFinder::GetTimeOfNextSpill(), SpillTimeFinder::GetTimeOfRecentSpill(), PulserDBModule::MergeBack(), AutoPIDMaker::Reco(), InfoChain::RemoveTemperatureEffects(), PulserGainFit::RunNearFarFits(), PulserGainFit::RunPinFits(), StndBmsSpin::Scan(), Summarizer::Summarize(), PulserFromRawCollectorModule::WriteRawCurveData(), PulserCollectorModule::WriteRawCurveData(), PulserFromRawCollectorModule::WriteRawDriftData(), PulserCollectorModule::WriteRawDriftData(), PulserCollectorModule::WriteReferenceDriftData(), DbuDaqMonitorModule::WriteSubRunSummaryEntry(), PulserTimingPoint::WriteToDatabase(), ScintCalTimePeriod::WriteToMINOSDbi(), DbuDaqMonitorModule::WriteVaChipPedsEntry(), and DbuDaqMonitorModule::WriteVaChipSparsEntry().

00286 {
00287    // Add "offset" as a delta time.
00288 
00289    fSec     += offset.fSec;
00290    fNanoSec += offset.fNanoSec;
00291    NormalizeNanoSec();
00292 
00293 }

const char * VldTimeStamp::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 120 of file VldTimeStamp.cxx.

References fNanoSec, and fSec.

Referenced by IoInputModule::AddFile(), PrintStat::Ana(), FiltMBSpillModule::Ana(), NDSgateTimeLooter::Ana(), EvtAddRawDigitBlockModule::Ana(), NoiseFilterModule::Ana(), EvtInfoInjectorModule::Ana(), VldContext::AsString(), VldRange::AsString(), DbiResultKey::AsString(), BDLivePlot::BDLivePlot(), UgliGeometry::BuildNodes(), RerootExodus::BuildVldContext(), DbuRunSummary::Commit(), DbuDaqFileSummary::Commit(), VldValidate::CompareTimeStamps(), GenieModule::Config(), DbiSqlContext::DbiSqlContext(), CoilTools::Distill(), PhotonStatSummarizer::DoesTableExist(), MuonDriftCalScheme::DoReset(), NuExtraction::ExtractBeamInfoDB(), NuAnalysis::ExtractConfig(), EvtOverlaySingleton::FindClosestDaqSnarl(), SpillTimeFinder::FindClosestEntries(), EvtOverlaySingleton::FindLowerBoundDaqMonitor(), Summarizer::FindNextContext(), RawSnarlHeaderBlock::FormatToOStream(), RawErrorStatsBlock::FormatToOStream(), RawRunConfigBlock::FormatToOStream(), RawQieErrorStatsBlock::FormatToOStream(), RawRunStartBlock::FormatToOStream(), RawConfigFilesBlock::FormatToOStream(), RawTrcMonitorBlock::FormatToOStream(), FabPlnInstall::FormatToOStream(), RawSubRunEndBlock::FormatToOStream(), RawRunCommentBlock::FormatToOStream(), RawPedestalTableBlock::FormatToOStream(), RawRunEndBlock::FormatToOStream(), RawQieDataBlock::FormatToOStream(), RawRopTdcRawDataBlock::FormatToOStream(), RawLinearizedDataBlock::FormatToOStream(), RawVtmTimeInfoBlock::FormatToOStream(), RawSparsifierTableBlock::FormatToOStream(), RawDigitCrateStatus::FormatToOStream(), RawTriggerStatsBlock::FormatToOStream(), RawVaTimingMonitorBlock::FormatToOStream(), RawLiTpmtDigitsBlock::FormatToOStream(), RawVarcErrorInTfBlock::FormatToOStream(), RawDaqDeadTimeBlock::FormatToOStream(), HepevtModule::Get(), RerootToTruthModule::Get(), DetSim::Get(), FileGap::GetFileBounds(), DbiValidityRec::GetL2CacheName(), CoilTools::GetLast(), MCMerge::GrabStreamEvents(), CoilTools::LocalQuery(), FabPlnInstallLookup::LookForOddEntries(), lootSpillFile(), Dbi::MakeDateTimeString(), EvtOverlaySingleton::MapDaqFiles(), operator<<(), SimSnarlHeader::Print(), DDSClientId::Print(), RecJobRecord::Print(), Print(), BeamMonSpill::Print(), MuonDriftCalScheme::PrintConfig(), PmtDriftCalScheme::PrintConfig(), PulserTimeCalScheme::PrintConfig(), DbuDaqMonitorModule::ProcessRawRecord(), DbuDaqFileModule::ProcessRawRecord(), PulserGainFit::PulserGainFit(), LIPlexMaps::ReadDbGains(), FillHvFromSingles::ReadFromDatabase(), EvtOverlaySingleton::ReadOneSpillTimesFile(), EvtAddRawDigitBlockModule::Reco(), DbiDBProxy::ReplaceInsertDate(), MBSpillAccessor::SeekClosest(), DbiSqlValPacket::SetCreationDate(), LISummarySorter::SetPlexHandle(), GenieModule::SetTimeStamp(), SpillTimeCreateKeyFile(), VldValidate::TestTimeStamp(), GeoGeometry::Time2MinervaVersion(), NDSgateTimeLooter::Write(), EventInfoPage::WriteInfo(), DbuDaqFileModule::WritePythonFile(), CoilTools::WriteRow(), DbuDaqMonitorModule::WriteSubRunSummaryEntry(), WriteTableToCSVFile(), FillSpillServerMon::WriteToDatabase(), FillHvFromSingles::WriteToDatabase(), and ScintCalTimePeriod::WriteToMINOSDbi().

00121 {
00122    // Return the date & time as a string.
00123    //
00124    // Result is pointer to a statically allocated string.
00125    // User should copy this into their own buffer before calling
00126    // this method again.  This is somewhat mitigated
00127    // by use of a circular buffer of strings.
00128    //
00129    // Option "l" returns it in local zone format
00130    // (can be applied to default or compact format).
00131    //
00132    // Default format is RFC822 compliant:
00133    //   "Mon, 02 Jan 2001 18:11:12 +0000 (GMT) +999999999 nsec"
00134    //   "Mon, 02 Jan 2001 10:11:12 -0800 (PST) +999999999 nsec"
00135    //
00136    // Option "c" compact is (almost) ISO 8601 compliant:
00137    //   "2001-01-02 18:11:12.9999999999Z"
00138    //   "2001-01-02 10:11:12.9999999999-0800"  if PST
00139    //      * uses "-" as date separator as specified in ISO 8601
00140    //      * uses "." rather than preferred "," for decimal separator
00141    //      * -HHMM is the difference between local and UTC (if behind, + if ahead).
00142    //   The "-HHMM" is replaced with "Z" if given as UTC.
00143    //   To be strictly conforming it should use "T" instead of the
00144    //   blank separating the date and time.
00145    //
00146    // Option "2" returns as {sec,nsec} integers.
00147    //
00148    // Option "s" returns "2001-01-02 18:11:12" with an implied UTC,
00149    // overrides "l" option.
00150 
00151    // Internally uses a circular list of buffers to avoid problems
00152    // using AsString multiple times in a single statement.
00153 
00154    const int nbuffers = 8;     // # of buffers
00155 
00156    static char formatted[nbuffers][64];  // strftime fields substituted
00157    static char formatted2[nbuffers][64]; // nanosec field substituted
00158    static int ibuffer = nbuffers;
00159    ibuffer = (ibuffer+1)%nbuffers; // each call moves to next buffer
00160 
00161    TString opt = option;
00162    opt.ToLower();
00163 
00164    if (opt.Contains("2")) {
00165       // return string formatted as integer {sec,nsec}
00166       sprintf(formatted[ibuffer], "{%10d,%9d}", fSec, fNanoSec);
00167       return formatted[ibuffer];
00168    }
00169 
00170 #ifdef linux
00171    // under linux %z is the hour offset and %Z is the timezone name
00172    const char *RFC822   = "%a, %d %b %Y %H:%M:%S %z (%Z) +#9ld nsec";
00173    const char *ISO8601  = "%Y-%m-%d %H:%M:%S.#9.9ld%z";
00174    const char *ISO8601Z = "%Y-%m-%d %H:%M:%S.#9.9ldZ";
00175 #else
00176    // otherwise only %Z is guarenteed to be defind
00177    const char *RFC822   = "%a, %d %b %Y %H:%M:%S %Z +#9ld nsec";
00178    const char *ISO8601  = "%Y-%m-%d %H:%M:%S.#9.9ld%Z";
00179    const char *ISO8601Z = "%Y-%m-%d %H:%M:%S.#9.9ldZ";
00180 #endif
00181    const char *SQL = "%Y-%m-%d %H:%M:%S";
00182 
00183    Bool_t asLocal = opt.Contains("l");
00184    Bool_t asSQL   = opt.Contains("s");
00185    if (asSQL) asLocal = kFALSE;
00186 
00187    const char *format = RFC822;
00188    if (opt.Contains("c")) {
00189       format = ISO8601;
00190       if (!asLocal) format = ISO8601Z;
00191    }
00192    if (asSQL) format = SQL;
00193 
00194    struct tm *ptm;
00195    time_t seconds = (time_t) fSec;   // deal with possible mismatch of types 
00196                                      // of fSec and the time_t required 
00197                                      // by functions
00198 
00199    // get the components into a tm struct
00200    ptm = (asLocal) ? localtime(&seconds) : gmtime(&seconds);
00201 
00202    // format all but the nsec field
00203    // size_t length =
00204    strftime(formatted[ibuffer], sizeof(formatted[ibuffer]), format, ptm);
00205 
00206    if (asSQL) return formatted[ibuffer];
00207 
00208    // hack in the nsec part
00209    char *ptr = strrchr(formatted[ibuffer], '#');
00210    if (ptr) *ptr = '%';    // substitute % for #
00211    sprintf(formatted2[ibuffer], formatted[ibuffer], fNanoSec);
00212 
00213    return formatted2[ibuffer];
00214 }

void VldTimeStamp::Copy ( VldTimeStamp vldts  )  const

Definition at line 217 of file VldTimeStamp.cxx.

References fNanoSec, and fSec.

Referenced by CheckGC::SettsEnd(), and CheckGC::SettsStart().

00218 {
00219    // Copy this to ts.
00220 
00221    ts.fSec     = fSec;
00222    ts.fNanoSec = fNanoSec;
00223 
00224 }

void VldTimeStamp::DumpTMStruct ( const tm_t tmstruct  )  [static]

Print out the "tm" structure:.

Definition at line 573 of file VldTimeStamp.cxx.

00574 {
00575    // Print out the "tm" structure:
00576    // tmstruct.tm_year = year;    // years since 1900
00577    // tmstruct.tm_mon  = month-1; // months since Jan [0,11]
00578    // tmstruct.tm_mday = day;     // day of the month [1,31]
00579    // tmstruct.tm_hour = hour;    // hours since midnight [0,23]
00580    // tmstruct.tm_min  = min;     // minutes after the hour [0,59]
00581    // tmstruct.tm_sec  = sec;     // seconds after the minute [0,59]
00582    // tmstruct.tm_wday            // day of week [0,6]
00583    // tmstruct.tm_yday            // days in year [0,365]
00584    // tmstruct.tm_isdst           // DST [-1/0/1]  (unknown,false,true)
00585 
00586    printf(" tm { year %4d, mon   %2d, day   %2d,\n",
00587           tmstruct.tm_year,
00588           tmstruct.tm_mon,
00589           tmstruct.tm_mday);
00590    printf("      hour   %2d, min   %2d, sec   %2d,\n",
00591           tmstruct.tm_hour,
00592           tmstruct.tm_min,
00593           tmstruct.tm_sec);
00594    printf("      wday   %2d, yday %3d, isdst %2d",
00595           tmstruct.tm_wday,
00596           tmstruct.tm_yday,
00597           tmstruct.tm_isdst);
00598 #ifdef linux
00599 //#ifdef __GNUC__
00600 // special GCC extras
00601    printf(",\n      tm_gmtoff %7ld,  tm_zone \"%s\"",
00602 #ifdef __USE_BSD
00603           tmstruct.tm_gmtoff,tmstruct.tm_zone);
00604 #else
00605           tmstruct.__tm_gmtoff,tmstruct.__tm_zone);
00606 #endif
00607 #endif
00608    printf("}\n");
00609 }

VldTimeStamp VldTimeStamp::GetBOT (  )  [static]
Int_t VldTimeStamp::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 227 of file VldTimeStamp.cxx.

References fSec.

Referenced by CountPot::Ana(), FitTrackMSListModule::Ana(), RateSummary::Ana(), TrackDirectionModule::Ana(), AlignmentAlgorithm::AnalyzeStripData(), RotoServer::BogusFileName(), RotoServer::BuildBeamMonBaseName(), RotoServer::BuildDcsBaseName(), CheckGC::checklin(), LIPlexMaps::CompareStripToStrip(), MadAnalysis::CreateANtpPAN(), CountPot::EndJob(), FarmListModule::FarmFileOUT(), NtpSRModule::FillNtpEventSummary(), NtpEMModule::FillNtpSummary(), NtpSRModule::FillNtpTrackCosmicRay(), AlignmentRunSummary::FillSummaryTree(), Anp::HistTime::HistTime(), FabPlnInstallLookup::LookForOddEntries(), Dbi::MakeTimeStamp(), Anp::FillHeader::Run(), SKZPWeightCalculator::RunPeriodIntFromValidity(), GenieModule::SetTimeStamp(), RunSummary::SFileOUT(), and VldValidate::TestTimeStamp().

00229 {
00230    // Return date in form of 19971224 (i.e. 24/12/1997),
00231    // if non-zero pointers supplied for year, month, day fill those as well
00232 
00233    time_t atime = fSec + secOffset;
00234    struct tm *ptm = (inUTC) ? gmtime(&atime) : localtime(&atime);
00235 
00236    if (year)  *year  = ptm->tm_year + 1900;
00237    if (month) *month = ptm->tm_mon + 1;
00238    if (day)   *day   = ptm->tm_mday;
00239 
00240    return (1900+ptm->tm_year)*10000 + (1+ptm->tm_mon)*100 + ptm->tm_mday;
00241 
00242 }

VldTimeStamp VldTimeStamp::GetEOT (  )  [static]
Int_t VldTimeStamp::GetNanoSec ( void   )  const [inline]

Get nanoseconds after the second.

Definition at line 163 of file VldTimeStamp.h.

References fNanoSec.

Referenced by TridModel::AddStrip(), SimDetector::AdjustTimeWithinSec(), LIStreamHunter::Ana(), FiltMBSpillModule::Ana(), MNtpModule::Ana(), RunSummary::Ana(), NDSgateTimeLooter::Ana(), EvtAddRawDigitBlockModule::Ana(), RawLILooker::Ana(), NoiseFilterModule::Ana(), FitTrackMSListModule::Ana(), ClockCalibrationModule::Ana(), CandDigitModule::Ana(), CheckND::Ana(), EvtInfoInjectorModule::Ana(), LISummaryAnalyser::Ana(), BeamMonAna::Analyze(), DetSim::CalculateAddTDC(), RawTofConverter::ConstructTofBlocks(), TridPageDetector::CreateModels(), MadDpAnalysis::CreatePAN(), MadTestAnalysis::CreatePAN(), MadPIDAnalysis::CreatePAN(), TridModelMaker::CreateShowerModels(), TridModelMaker::CreateSliceModels(), TridModelMaker::CreateTrackModels(), MadCluAnalysis::DataDistributions(), NuAnalysis::ExtractConfig(), NuExtraction::ExtractDataQuality(), NuExtraction::ExtractGeneralInfo(), NuExtraction::ExtractTimeToNearestSpill(), NtpTimingNtuple::Fill(), ANtpInfoObjectFillerBeam::FillBeamInformation(), NtpBDLiteModule::FillNtpBDLite(), NtpSRModule::FillNtpTimeStatus(), NtpMaker::FillSpillInfo(), ANtpEventInfoAna::FillStripVariables(), MeuCuts::FillSTSumDetails(), DataStabilityAnalysisClass::FillTTree(), RawSubRunEndBlock::FormatToOStream(), RawRunEndBlock::FormatToOStream(), DetSim::Get(), EvtOverlaySingleton::GetCrateT0s(), LISummarySorter::GetElectronicsData(), MadTVAnalysis::GetEvtTimeChar(), LISummaryModule::GetPulserBlocks(), LISummaryModule::GetSummaryBlocks(), SpillTimeFinder::GetTimeDifference(), SpillServerMonFinder::GetTimeDifference(), operator-(), PulserTimingPoint::PointTimedOut(), minos::PostOnWhiteBoard(), DQRawDigits::Process(), DQHotColdElectronics::Process(), DQHeader::Process(), DataQualityInterface::ProcessBeamStatus(), FillFarRunQuality::ProcessBlock(), FillNearRunQuality::ProcessBlock(), FillHvFromSingles::ProcessBlock(), FillBadChannelDB::ProcessBlock(), DataQualityInterface::ProcessDetectorStatus(), DataUtil::QueryBeamDB(), RawBeamMonHeaderBlock::RawBeamMonHeaderBlock(), RawConfigFilesBlock::RawConfigFilesBlock(), RawDaqDeadTimeBlock::RawDaqDeadTimeBlock(), RawDaqHeaderBlock::RawDaqHeaderBlock(), RawDcsHeaderBlock::RawDcsHeaderBlock(), RawErrorStatsBlock::RawErrorStatsBlock(), RawQieErrorStatsBlock::RawQieErrorStatsBlock(), RawRunCommentBlock::RawRunCommentBlock(), RawRunConfigBlock::RawRunConfigBlock(), RawRunEndBlock::RawRunEndBlock(), RawRunStartBlock::RawRunStartBlock(), RawSnarlHeaderBlock::RawSnarlHeaderBlock(), RawSpillServerMonitorBlock::RawSpillServerMonitorBlock(), RawSubRunEndBlock::RawSubRunEndBlock(), RawTpSinglesSummaryBlock::RawTpSinglesSummaryBlock(), RawTriggerStatsBlock::RawTriggerStatsBlock(), MnvRawDigitSuppression::Reco(), OltBlockScan::Reco(), Anp::FillHeader::Run(), PhotonInjector::SimulateEvent(), BeamMonFileSummary::Store(), and BeamMonSpill::Store().

00163 { return fNanoSec; }

VldTimeStamp VldTimeStamp::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 73 of file VldTimeStamp.cxx.

References VldTimeStamp().

00074 {
00075     return VldTimeStamp((time_t)INT_MIN,0);
00076 }

time_t VldTimeStamp::GetSec ( void   )  const [inline]

Get (integral) seconds after the EPOCH.

Definition at line 161 of file VldTimeStamp.h.

References fSec.

Referenced by DetSim::AddToCrate(), RerootToRawDataModule::AddToCrate(), PerInputStreamManager::AdvanceRecordTags(), DataQualityFilter::Ana(), LIStreamHunter::Ana(), FiltMBSpillModule::Ana(), MNtpModule::Ana(), DDSPaceModule::Ana(), RunSummary::Ana(), UberDST::Ana(), NDSgateTimeLooter::Ana(), CDAnaModule::Ana(), EvtAddRawDigitBlockModule::Ana(), RawLILooker::Ana(), FitTrackMSListModule::Ana(), RateSummary::Ana(), TrackDirectionModule::Ana(), CDTrackerModule::Ana(), CheckND::Ana(), LISummaryAnalyser::Ana(), BeamMonAna::Analyze(), AlignmentAlgorithm::AnalyzeStripData(), BeamMonSpill::BeamType(), RerootExodus::BuildVldRange(), BDSpillAccessor::CalibrateSpill(), BDSpliceModule::Config(), RawTofConverter::ConstructTofBlocks(), MadAnalysis::CreateANtpPAN(), PulserTimePlotter::CreateGraph(), MadDpAnalysis::CreatePAN(), MadTestAnalysis::CreatePAN(), MadPIDAnalysis::CreatePAN(), MadCluAnalysis::DataDistributions(), SpillServerMonFinder::DataIsAvailable(), DbiValidityRecBuilder::DbiValidityRecBuilder(), BMSpillFiller::DBU(), ParticleBeamMonAna::DetermineBeamType(), NueModule::DetermineBeamType(), LIPlexMaps::DriftWithTime(), NuAnalysis::EnergySpect(), HvStatusFinder::ExtendedQuery(), NuAnalysis::ExtractConfig(), NuExtraction::ExtractDataQuality(), NuExtraction::ExtractGeneralInfo(), NuExtraction::ExtractTimeToNearestSpill(), FarmListModule::FarmFileOUT(), RunSummary::FilesOUT(), DbuRunSummary::Fill(), NtpTimingNtuple::Fill(), ANtpInfoObjectFillerBeam::FillBeamInformation(), NueMiniAnaPID::FillMini(), NueMiniAna::FillMini(), NtpBDLiteModule::FillNtpBDLite(), NtpSRModule::FillNtpEventSummary(), NtpEMModule::FillNtpSummary(), NtpMaker::FillSpillInfo(), MeuCuts::FillSTSumDetails(), AlignmentRunSummary::FillSummaryTree(), DataStabilityAnalysisClass::FillTTree(), SpillServerMonFinder::FindClosestEntries(), SpillTimeFinder::FindClosestEntries(), DbiDBProxy::FindTimeBoundaries(), FitNdNonlinQuad(), RawSubRunEndBlock::FormatToOStream(), RawRunEndBlock::FormatToOStream(), BMSpillAna::FractionOnTarget(), MCMerge::Get(), RerootToRawDataModule::Get(), DetSim::Get(), LISummarySorter::GetElectronicsData(), DataQualityLookup::GetFarDetCoilStatus(), DataQualityLookup::GetFarDetHvStatus(), FarTimingFidFinder::GetFarTimingFid(), HvStatusFinder::GetHvStatus(), SpillTimeFinder::GetOffsetSgateToNDNu(), LISummaryModule::GetPulserBlocks(), DbiDemoData3::GetRangeDTF(), PerOutputStreamManager::GetRecordTimeSec(), RunQualityFinder::GetRun(), DataUtil::GetRunTimes(), SpillServerMonFinder::GetSpillTimeError(), RunQualityFinder::GetStatus(), RunQualityFinder::GetSubRun(), LISummaryModule::GetSummaryBlocks(), SpillTimeFinder::GetTimeDifference(), SpillServerMonFinder::GetTimeDifference(), Anp::HistTime::HistTime(), CoilTools::IsCoilStateOK(), CoilTools::IsCoilStateReverse(), DataUtil::IsGoodDataGPS(), RunQualityFinder::IsOK(), NueStandard::IsRun1(), NueStandard::IsRun10(), NueStandard::IsRun11(), NueStandard::IsRun12(), NueStandard::IsRun13(), NueStandard::IsRun2(), NueStandard::IsRun3NotPrime(), NueStandard::IsRun3Prime(), NueStandard::IsRun4(), NueStandard::IsRun4RHC(), NueStandard::IsRun5(), NueStandard::IsRun6(), NueStandard::IsRun7RHC(), NueStandard::IsRun8(), NueStandard::IsRun9RHC(), NueStandard::IsSpecialRun(), NuAnalysis::LIRejectionTest(), HvStatusFinder::LocalQuery(), main(), PEGainModule::MakeDebugTree(), DbiValidityRecBuilder::MakeGapRec(), DDSChildServer::Next(), DbiResultPtr< T >::NextQuery(), operator-(), oracleTimeStamp(), NueStandard::PassesPOTStandards(), PulserTimingPoint::PointTimedOut(), minos::PostOnWhiteBoard(), DDSClientId::Print(), LISummarySorter::PrintBlockInfo(), LISummaryModule::PrintBlockInfo(), DQRawDigits::Process(), DQHotColdElectronics::Process(), DQHeader::Process(), DQLightInjection::Process(), DataQualityInterface::ProcessBeamStatus(), FillFarRunQuality::ProcessBlock(), FillSpillServerMon::ProcessBlock(), FillHvFromSingles::ProcessBlock(), DataQualityInterface::ProcessDetectorStatus(), FillNearRunQuality::ProcessHeader(), FillFarRunQuality::ProcessHeader(), FillBadChannelDB::ProcessHeader(), DcsWriter::ProcessRawRecord(), DbuDaqMonitorModule::ProcessRawRecord(), DbuDaqFileModule::ProcessRawRecord(), DataUtil::QueryBeamDB(), RunQualityFinder::QueryDB(), DbiDBProxy::QueryValidity(), RawBeamMonHeaderBlock::RawBeamMonHeaderBlock(), RawConfigFilesBlock::RawConfigFilesBlock(), RawDaqDeadTimeBlock::RawDaqDeadTimeBlock(), RawDaqHeaderBlock::RawDaqHeaderBlock(), RawDcsHeaderBlock::RawDcsHeaderBlock(), RawErrorStatsBlock::RawErrorStatsBlock(), RawQieErrorStatsBlock::RawQieErrorStatsBlock(), RawRunCommentBlock::RawRunCommentBlock(), RawRunConfigBlock::RawRunConfigBlock(), RawRunEndBlock::RawRunEndBlock(), RawRunStartBlock::RawRunStartBlock(), RawSnarlHeaderBlock::RawSnarlHeaderBlock(), RawSpillServerMonitorBlock::RawSpillServerMonitorBlock(), RawSubRunEndBlock::RawSubRunEndBlock(), RawTpSinglesSummaryBlock::RawTpSinglesSummaryBlock(), RawTriggerStatsBlock::RawTriggerStatsBlock(), FillFarRunQuality::ReadFromDatabase(), FillNearRunQuality::ReadFromDatabase(), PulserFromRawModule::Reco(), OltBlockScan::Reco(), UberModule::Reco(), PulserSummaryModule::Reco(), UberModuleLite::Reco(), InfoChain::RemoveTemperatureEffects(), Anp::FillHeader::Run(), LISummarySorter::SetPlexHandle(), RunSummary::SFileOUT(), SpillTimeCreateKeyFile(), CDAnalysis::StoppingMuonCalibration(), PerOutputStream::Store(), Detector::Update(), EventInfoPage::WriteInfo(), and ScintCalTimePeriod::WriteToMINOSDbi().

00161 { return fSec;}

Double_t VldTimeStamp::GetSeconds ( void   )  const [inline]
Int_t VldTimeStamp::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 245 of file VldTimeStamp.cxx.

References fSec.

Referenced by FitTrackMSListModule::Ana(), TrackDirectionModule::Ana(), AlignmentAlgorithm::AnalyzeStripData(), RotoServer::BogusFileName(), RotoServer::BuildBeamMonBaseName(), RotoServer::BuildDcsBaseName(), MadAnalysis::CreateANtpPAN(), Anp::HistTime::Fill(), NtpSRModule::FillNtpEventSummary(), NtpEMModule::FillNtpSummary(), NtpSRModule::FillNtpTrackCosmicRay(), AlignmentRunSummary::FillSummaryTree(), GenieModule::SetTimeStamp(), and VldValidate::TestTimeStamp().

00247 {
00248    // Return time in form of 123623 (i.e. 12:36:23),
00249    // if non-zero pointers supplied for hour, min, sec fill those as well
00250 
00251    time_t atime = fSec + secOffset;
00252    struct tm *ptm = (inUTC) ? gmtime(&atime) : localtime(&atime);
00253 
00254    if (hour) *hour = ptm->tm_hour;
00255    if (min)  *min  = ptm->tm_min;
00256    if (sec)  *sec  = ptm->tm_sec;
00257 
00258    return ptm->tm_hour*10000 + ptm->tm_min*100 + ptm->tm_sec;
00259 
00260 }

timespec_t VldTimeStamp::GetTimeSpec (  )  const [inline]

Get timestamp as a timespec_t.

Definition at line 157 of file VldTimeStamp.h.

References fNanoSec, and fSec.

Referenced by VldValidate::TestTimeStamp().

00158       { timespec_t value = {fSec,fNanoSec}; return value; }

Int_t VldTimeStamp::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 263 of file VldTimeStamp.cxx.

Referenced by VldValidate::TestTimeStamp().

00264 {
00265    // Static method returning local (current) time zone offset from UTC.
00266    // This is the difference in seconds between UTC and local standard time.
00267 
00268    // ?? should tzset (_tzset) be called?
00269 #ifndef R__WIN32
00270    tzset();
00271 #if !defined(R__MACOSX) && !defined(R__FBSD)
00272    return  timezone;   /* unix has extern long int */
00273 #else
00274    time_t *tp = 0;
00275    time(tp);
00276    return localtime(tp)->tm_gmtoff;
00277 #endif
00278 #else
00279    _tzset();
00280    return _timezone;   /* Win32 prepends "_" */
00281 #endif
00282 }

Bool_t VldTimeStamp::IsLeapYear ( Int_t  year  )  [static]

Is the given year a leap year.

Definition at line 539 of file VldTimeStamp.cxx.

Referenced by MktimeFromUTC().

00540 {
00541    // Is the given year a leap year.
00542 
00543 
00544    // The calendar year is 365 days long, unless the year is exactly divisible
00545    // by 4, in which case an extra day is added to February to make the year
00546    // 366 days long. If the year is the last year of a century, eg. 1700, 1800,
00547    // 1900, 2000, then it is only a leap year if it is exactly divisible by
00548    // 400. Therefore, 1900 wasn't a leap year but 2000 was. The reason for
00549    // these rules is to bring the average length of the calendar year into
00550    // line with the length of the Earth's orbit around the Sun, so that the
00551    // seasons always occur during the same months each year.
00552 
00553    if (year%4 != 0) {
00554       return false;
00555    }
00556    else {
00557       if (year%400 == 0) {
00558          return true;
00559       }
00560       else { 
00561          if (year%100 == 0) {
00562             return false;
00563          }
00564          else {
00565             return true;
00566          }
00567       }
00568    }
00569 
00570 }

time_t VldTimeStamp::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 481 of file VldTimeStamp.cxx.

References IsLeapYear(), and Munits::year.

Referenced by Set().

00482 {
00483    // Equivalent of standard routine "mktime" but
00484    // using the assumption that tm struct is filled with UTC, not local, time.
00485 
00486    // This version *ISN'T* configured to handle every possible
00487    // weirdness of out-of-range values in the case of normalizing
00488    // the tm struct.
00489 
00490    // This version *DOESN'T* correctly handle values that can't be
00491    // fit into a time_t (i.e. beyond year 2038-01-18 19:14:07, or
00492    // before the start of Epoch).
00493 
00494    const Int_t days[]     = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
00495    const Int_t daysLeap[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
00496 
00497    Int_t year = tmstruct->tm_year + 1900;
00498    Bool_t isleap = VldTimeStamp::IsLeapYear(year);
00499 
00500    const Int_t *daysInMonth = days;
00501    if (isleap) daysInMonth = daysLeap;
00502 
00503    // fill in tmstruct->tm_yday
00504 
00505    int &ref_tm_mon = tmstruct->tm_mon;
00506    int &ref_tm_mday = tmstruct->tm_mday;
00507    // count days in months past
00508    tmstruct->tm_yday = 0;
00509    for (Int_t imonth = 0; imonth < ref_tm_mon; imonth++) {
00510       tmstruct->tm_yday += daysInMonth[imonth];
00511    }
00512    tmstruct->tm_yday += ref_tm_mday - 1;  // day [1-31] but yday [0-365]
00513 
00514    // adjust if day in this month is more than the month has
00515    while (ref_tm_mday > daysInMonth[ref_tm_mon]) {
00516       ref_tm_mday -= daysInMonth[ref_tm_mon];
00517       ref_tm_mon++;
00518    }
00519 
00520    // *should* calculate tm_wday (0-6) here ...
00521 
00522    // UTC is never DST
00523    tmstruct->tm_isdst = 0;
00524 
00525    // Calculate seconds since the Epoch based on formula in
00526    // POSIX  IEEEE Std 1003.1b-1993 pg 22
00527 
00528    Int_t utc_sec = tmstruct->tm_sec +
00529                    tmstruct->tm_min*60 +
00530                    tmstruct->tm_hour*3600 +
00531                    tmstruct->tm_yday*86400 +
00532                    (tmstruct->tm_year-70)*31536000 +
00533                    ((tmstruct->tm_year-69)/4)*86400;
00534 
00535    return utc_sec;
00536 }

void VldTimeStamp::NormalizeNanoSec (  )  [private]

Definition at line 465 of file VldTimeStamp.cxx.

References fNanoSec, fSec, and kNsPerSec.

Referenced by Add(), Set(), and VldTimeStamp().

00466 {
00467    // Ensure that the fNanoSec field is in range [0,99999999].
00468 
00469    // deal with negative values
00470    while (fNanoSec < 0) {
00471       fNanoSec += kNsPerSec;
00472       fSec -= 1;
00473    }
00474    // deal with values inf fNanoSec greater than one sec
00475    while (fNanoSec >= kNsPerSec) {
00476       fNanoSec -= kNsPerSec;
00477       fSec += 1;
00478    }
00479 }

VldTimeStamp::operator double (  )  const [inline]

Implicitly convert a VldTimeStamp to a double.

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

Definition at line 153 of file VldTimeStamp.h.

References fNanoSec, and fSec.

00153 { return fSec + 1.0e-9 * fNanoSec; }

VldTimeStamp& VldTimeStamp::operator= ( const VldTimeStamp source  )  [inline]

Assignment.

Definition at line 95 of file VldTimeStamp.h.

References fNanoSec, and fSec.

00096       { if (this != &source) {fSec = source.fSec; fNanoSec = source.fNanoSec;}
00097       return *this; }

void VldTimeStamp::Print ( Option_t *  option = ""  )  const
void VldTimeStamp::Set ( Int_t  date,
Int_t  time,
Int_t  nsec,
Bool_t  isUTC,
Int_t  secOffset 
) [private]

Definition at line 424 of file VldTimeStamp.cxx.

References Munits::day, Munits::hour, min, month, Set(), and Munits::year.

00426 {
00427    // Set date/time from integers of the form [yy]YYMMDD and HHMMSS,
00428    // assume UTC (UTC) components:
00429    //
00430    //  MM: 01=January .. 12=December
00431    //  DD: 01 .. 31
00432    //
00433    //  HH: 00=midnight .. 23
00434    //  MM: 00 .. 59
00435    //  SS: 00 .. 69
00436    //
00437    // Date must be in format 980418 or 19980418
00438    //                       1001127 or 20001127  (i.e. year 100 = 2000).
00439    // Time must be in format 224512 (second precision).
00440    // Date must be >= 700101.
00441 
00442    Int_t year  = date/10000;
00443    Int_t month = (date-year*10000)/100;
00444    Int_t day   = date%100;
00445 
00446    // protect against odd attempts at time offsets
00447    const Int_t oneday = 240000;
00448    while (time < 0) {
00449       time += oneday;
00450       day  -= 1;
00451    }
00452    while (time > oneday) {
00453       time -= oneday;
00454       day  += 1;
00455    }
00456    Int_t hour  = time/10000;
00457    Int_t min   = (time-hour*10000)/100;
00458    Int_t sec   = time%100;
00459 
00460    Set(year, month, day, hour, min, sec, nsec, isUTC, secOffset);
00461 
00462 }

void VldTimeStamp::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 370 of file VldTimeStamp.cxx.

References fNanoSec, fSec, Msg::kInfo, MktimeFromUTC(), MSG, and NormalizeNanoSec().

00373 {
00374    // Set Date/Time from components.
00375    // 
00376    // month & day both use normal 1..12 and 1..31 counting
00377    // hours, min, sec run from 0 to 23, 59, 59 respectively;
00378    // secOffset provides method for adjusting for alternative timezones
00379    //
00380    // "year"  |    0    1 ... 37 | 38...69   |   70 .. 100  101 ..  137
00381    // true    | 2000 2001   2037 | undefined | 1970   2000 2001 .. 2037
00382    //
00383    // "year"  | 138...1969 | 1970 .. 2037 | ...
00384    // true    | undefined  | 1970 .. 2037 | undefined
00385    //
00386 
00387 
00388    // deal with special formats of year
00389    if (year <= 37)                year += 2000;
00390    if (year >= 70 && year <= 137) year += 1900;
00391    // tm.tm_year is years since 1900
00392    if (year >= 1900)              year -= 1900;
00393 
00394    struct tm tmstruct;
00395    tmstruct.tm_year  = year;    // years since 1900
00396    tmstruct.tm_mon   = month-1; // months since Jan [0,11]
00397    tmstruct.tm_mday  = day;     // day of the month [1,31]
00398    tmstruct.tm_hour  = hour;    // hours since midnight [0,23]
00399    tmstruct.tm_min   = min;     // minutes after the hour [0,59]
00400    tmstruct.tm_sec   = sec + secOffset;  // seconds after the minute [0,59]
00401    tmstruct.tm_isdst = -1;     // let "mktime" determine DST setting
00402 
00403    const time_t bad_time_t = (time_t) -1;
00404    // convert tm struct to time_t, if values are given in UTC then
00405    // no standard routine exists and we'll have to use our homegrown routine,
00406    // if values are given in local time then use "mktime"
00407    // which also normalizes the tm struct as a byproduct
00408    time_t utc_sec = (isUTC) ? MktimeFromUTC(&tmstruct) : mktime(&tmstruct);
00409  
00410    //   VldTimeStamp::Dump_tm_struct(tmstruct);
00411 
00412    if (utc_sec == bad_time_t) {
00413       MSG("Vld",Msg::kInfo) 
00414          << "VldTimeStamp::Set mktime returned -1" << endl;
00415    }
00416 
00417    fSec  = utc_sec;
00418    fNanoSec = nsec;
00419 
00420    NormalizeNanoSec();
00421 }

void VldTimeStamp::Set (  )  [private]

Definition at line 320 of file VldTimeStamp.cxx.

References fNanoSec, and fSec.

Referenced by Set(), and VldTimeStamp().

00321 {
00322    // Set Date/Time to current time as reported by the system.
00323    // no accounting for nanoseconds with std ANSI functions,
00324    // ns part faked so that subsequent calls simply add 1 to it
00325    // this ensures that calls within the same second come back
00326    // distinct (and sortable).
00327 
00328 #ifdef R__WIN32
00329    ULARGE_INTEGER time;
00330    GetSystemTimeAsFileTime((FILETIME *)&time);
00331    // NT keeps time in FILETIME format which is 100ns ticks since
00332    // Jan 1, 1601. TTimeStamps use time in 100ns ticks since Jan 1, 1970.
00333    // The difference is 134774 days.
00334    fNanoSec = Int_t((time.QuadPart * (unsigned __int64) 100) %
00335                     (unsigned __int64) 1000000000);
00336    time.QuadPart -=
00337             (unsigned __int64) (1000*1000*10)       // seconds
00338           * (unsigned __int64) (60 * 60 * 24)       // days
00339           * (unsigned __int64) (134774);            // # of days
00340 
00341    fSec     = Int_t(time.QuadPart/(unsigned __int64) (1000*1000*10));
00342 #else
00343    // this should work on UNIX to get microsec precision
00344    // we'll stick to a ns hack to make calls unique
00345    struct timeval now;
00346    if (!gettimeofday(&now,0)) {
00347       fSec     = now.tv_sec;
00348       fNanoSec = now.tv_usec * 1000;
00349    }
00350    else {
00351       time_t nowtime;
00352       time(&nowtime);
00353       fSec     = nowtime;
00354       fNanoSec = 0;
00355    }
00356 #endif
00357    static Int_t sec = 0, nsec = 0, fake_ns = 0;
00358 
00359    if (fSec == sec && fNanoSec == nsec)
00360       fNanoSec += ++fake_ns;
00361    else {
00362       fake_ns = 0;
00363       sec     = fSec;
00364       nsec    = fNanoSec;
00365    }
00366 
00367 }


Friends And Related Function Documentation

Bool_t operator!= ( const VldTimeStamp lhs,
const VldTimeStamp rhs 
) [friend]
VldTimeStamp operator- ( const VldTimeStamp lhs,
const VldTimeStamp rhs 
) [friend]
Bool_t operator< ( const VldTimeStamp lhs,
const VldTimeStamp rhs 
) [friend]
Bool_t operator<= ( const VldTimeStamp lhs,
const VldTimeStamp rhs 
) [friend]
Bool_t operator== ( const VldTimeStamp lhs,
const VldTimeStamp rhs 
) [friend]
Bool_t operator> ( const VldTimeStamp lhs,
const VldTimeStamp rhs 
) [friend]
Bool_t operator>= ( const VldTimeStamp lhs,
const VldTimeStamp rhs 
) [friend]

Member Data Documentation

Int_t VldTimeStamp::fNanoSec [private]
Int_t VldTimeStamp::fSec [private]

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

Generated on 21 Oct 2017 for loon by  doxygen 1.6.1