List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
utl::TimeStamp Class Reference

A TimeStamp holds GPS second and nanosecond for some event. More...

#include "utl/TimeStamp.h"

Public Member Functions

double GetGPSNanoSecond () const
 GPS nanosecond. More...
 
unsigned long GetGPSSecond () const
 GPS second. More...
 
 operator bool () const
 
bool operator!= (const TimeStamp &ts) const
 
TimeStamp operator+ (const TimeInterval &ti) const
 [TimeStamp] + [TimeInterval] = [TimeStamp] More...
 
TimeStampoperator+= (const TimeInterval &ti)
 [TimeStamp] += [TimeInterval] = [TimeStamp] More...
 
TimeInterval operator- (const TimeStamp &ts) const
 [TimeStamp] - [TimeStamp] = [TimeInterval] More...
 
TimeStamp operator- (const TimeInterval &ti) const
 [TimeStamp] - [TimeInterval] = [TimeStamp] More...
 
TimeStampoperator-= (const TimeInterval &ti)
 [TimeStamp] -= [TimeInterval] = [TimeStamp] More...
 
bool operator< (const TimeStamp &ts) const
 
bool operator<= (const TimeStamp &ts) const
 
bool operator== (const TimeStamp &ts) const
 
bool operator> (const TimeStamp &ts) const
 
bool operator>= (const TimeStamp &ts) const
 
void SetGPSTime (const unsigned long sec, const double nsec=0)
 Set GPS second and (optionally) nanosecond. More...
 
 TimeStamp ()
 
 TimeStamp (const long sec, const double nsec=0)
 Construct from GPS second and nanosecond. More...
 

Static Public Member Functions

static TimeStamp Max ()
 

Private Member Functions

void SetNormalized (long sec, double nsec)
 Take care of positive nanosecond and GPS epoch. More...
 

Private Attributes

double fGPSNanoSecond
 
unsigned long fGPSSecond
 

Detailed Description

A TimeStamp holds GPS second and nanosecond for some event.

Introduction

This class holds a GPS second and nanosecond and provides methods to convert to seconds since Unix Epoch or to UTC, with proper accounting for leap seconds. Methods are also provided to return Modified Julian Date and formatted strings with UTC printout consistent with the conventions document, as well as strings of XML with date and time information.

A utl::TimeStamp represents the time of occurrence of some event. To represent time intervals between events, use the TimeInterval class. A number of arithmetic operations are defined between utl::TimeStamp and utl::TimeInterval. For example:

TimeStamp - TimeStamp = TimeInterval
TimeStamp - TimeInterval = TimeStamp
TimeStamp + TimeInterval = TimeStamp
TimeInterval + TimeInterval = TimeInterval

Time conventions

What is time? This is a brief summary of time systems, relevant for the Auger project operation (see http://tycho.usno.navy.mil/gpstt.html for details).

Why not just use unix time?

The utl::TimeStamp class will not allow you to initialize a TimeStamp using a unix time_t. You may wonder why this is, or wonder why we don't just use unix time for everything, since the c time library has functions already built in for converting unix seconds to UTC.

The reason is that, in a nutshell, unix time is broken. For some reason the POSIX standard requires the time_t to count seconds since Unix epoch not including leap seconds. This means calculating time intervals by subtracting unix times across a leap second will give the wrong result. Furthermore, initializing a TimeStamp with a time_t at the leap second boundary would be ambiguous; there are two GPS seconds corresponding to the unix second at the time of the leap second. It may seem that this would only rarely pose a problem, but on the other hand it is not particularly difficult to just do it correctly.

Author
T. Paul
D. Veberic
Date
19 Feb 2003

Definition at line 110 of file TimeStamp.h.

Constructor & Destructor Documentation

utl::TimeStamp::TimeStamp ( )
inline

Definition at line 113 of file TimeStamp.h.

Referenced by Max(), operator+(), and operator-().

utl::TimeStamp::TimeStamp ( const long  sec,
const double  nsec = 0 
)
inline

Construct from GPS second and nanosecond.

Definition at line 116 of file TimeStamp.h.

References SetNormalized().

Member Function Documentation

double utl::TimeStamp::GetGPSNanoSecond ( ) const
inline

GPS nanosecond.

Definition at line 127 of file TimeStamp.h.

References fGPSNanoSecond.

Referenced by RdAirplane::Util::ApproximatedGPSTimeStampFromTimestamp(), CentralTriggerEventBuilderNS::CentralTriggerEventBuilder::BuildEvent(), FdLightCollectionEfficiencyKG::FdLightCollectionEfficiency::CalculateTelescopeEfficiency(), io::cevtStation_ROOT::cevtStation_ROOT(), FdAxisFinderOG::FdAxisFinder::CheckForLasers(), evt::ConvertEventToEr(), evt::ConvertEventToIoSd(), RdREASSimPreparatorNG::RdREASSimPreparatorNG::CreateCoREASContent(), RdZHAireSSimPreparator::RdZHAireSSimPreparator::CreateFiles(), SdRecPlotterOG::SdRecPlotter::DrawEvent(), RdEVASimPreparator::RdEVASimPreparator::EVAFileWriter(), otoa::FD2ADST::FillEyeHeader(), otoa::FD2ADST::FillFdCoreAxis(), otoa::FD2ADST::FillFdRecStations(), otoa::RdFiller::FillRadioEventInfo(), otoa::MD2ADST::FillRecShower(), StereoGeometryFinderOG::StereoGeometryFinder::FindAxisStereo(), StereoGeometryFinderOG::StereoGeometryFinder::FindAxisStereoHybrid(), RdChannelNoiseImporter_AERA::RdChannelNoiseImporter_AERA::GetNoiseFileName(), FdTriggerSimulatorOG::FdTriggerSimulator::MakeMirrorEvent(), HdAxisFinderUU::HdAxisFinder::MinuitFitFunc(), HybridGeometryFinderOG::HybridGeometryFinder::MinuitFitFuncHybrid(), StereoGeometryFinderOG::StereoGeometryFinder::MinuitFitFuncStereo(), StereoGeometryFinderOG::StereoGeometryFinder::MinuitFitFuncStereoHybrid(), utl::operator<<(), UnivFitterKG::Fitter::printResults(), io::ZHAireSFile::Read(), RdREASSimPreparator::RdREASSimPreparator::REASFileWriter(), SdMonteCarloPropagatorKVI::SdMonteCarloPropagator::Run(), RdREASSimPreparator::RdREASSimPreparator::Run(), RdCOREASSimulationCreator::RdCOREASSimulationCreator::Run(), UnderGrdInjectorAG::UnderGrdInjector::Run(), Validatrix::Validatrix::Run(), io::TimeStamp_ROOT::Set(), TestTime::TestArithmetic(), TestTime::TestTimeStampInitialization(), utl::UTCDateTime::UTCDateTime(), utlPython(), and RdChannelBeaconTimingCalibrator::RdChannelBeaconTimingCalibrator::writeDebugFile().

unsigned long utl::TimeStamp::GetGPSSecond ( ) const
inline

GPS second.

Definition at line 124 of file TimeStamp.h.

References fGPSSecond.

Referenced by FdTriggerSimulatorOG::FdTriggerSimulator::AddEyeEvent(), RdAirplane::Util::ApproximatedGPSTimeStampFromTimestamp(), rdet::MonitoringSQLManager::BufferTemperature(), CentralTriggerEventBuilderNS::CentralTriggerEventBuilder::BuildEvent(), io::cevtStation_ROOT::cevtStation_ROOT(), evt::ConvertEventToIoSd(), RdREASSimPreparatorNG::RdREASSimPreparatorNG::CreateCoREASContent(), RdZHAireSSimPreparator::RdZHAireSSimPreparator::CreateFiles(), SdRecPlotterOG::SdRecPlotter::DrawEvent(), FdSimEventCheckerOG::FdSimEventChecker::DumpDB(), RdEVASimPreparator::RdEVASimPreparator::EVAFileWriter(), otoa::Detector2ADST::FillDetector(), otoa::FD2ADST::FillEyeHeader(), otoa::FD2ADST::FillFdCoreAxis(), otoa::RdFiller::FillRadioEventInfo(), otoa::MD2ADST::FillRecShower(), FdCalibratorOG::FdCalibrator::FillTriggerData(), rdet::RBadStationSQLManager::GetBadPeriodFromBuffer(), SdSimpleSimKG::SdSimpleSim::GetCDASTriggerTimeWindow(), rdet::RChannelSQLManager::GetChannelListFromBuffer(), rdet::RChannelSQLManager::GetComponentFromBuffer(), atm::AGOESSQLManager::GetDBResFundamental(), atm::ALidarSQLManager::GetDBResFundamental(), atm::ACloudSQLManager::GetDBResFundamental(), atm::AOverallQualitySQLManager::GetDBResFundamental(), atm::AAerosolSQLManager::GetDBResFundamental(), atm::AMolecularSQLManager::GetDBResFundamental(), atm::AMolecularSQLManager::GetDBResVector(), RdChannelNoiseImporter_AERA::RdChannelNoiseImporter_AERA::GetNoiseFileName(), fdet::FParametricOpticalEfficiencyLossManager::GetOpticalEfficiencyCorrectionForTelescope(), fdet::FOpticalEfficiencyLossSQLManager::GetOpticalEfficiencyCorrectionForTelescope(), fdet::FdAlwaysUpManager::GetStatus(), rdet::MonitoringSQLManager::GetTemperature(), fdet::FCalibSQLManager::GetWorkingCalibId(), RdStationNoiseAnalyser::Init(), UniversalityFitter::UniversalityFitter::InitBarilocheReconstruction(), FdTriggerSimulatorOG::FdTriggerSimulator::MakeMirrorEvent(), HybridGeometryFinderOG::HybridGeometryFinder::MinuitFitFuncHybrid(), utl::ModifiedJulianDate(), io::operator<<(), utl::operator<<(), UnivFitterKG::Fitter::printResults(), io::ZHAireSFile::Read(), RdREASSimPreparator::RdREASSimPreparator::REASFileWriter(), SdInspectorOG::SdInspector::Run(), RdStationSimPulseFinder::RdStationSimPulseFinder::Run(), RdChannelDebugWriter::RdChannelDebugWriter::Run(), SdMonteCarloPropagatorKVI::SdMonteCarloPropagator::Run(), RdEventPreSelector::RdEventPreSelector::Run(), RdEventInitializer::RdEventInitializer::Run(), RdREASSimPreparator::RdREASSimPreparator::Run(), RdStationNoiseAnalyser::Run(), RdCOREASSimulationCreator::RdCOREASSimulationCreator::Run(), RdEventMerger::RdEventMerger::Run(), RdGalacticDatasetMaker::RdGalacticDatasetMaker::Run(), RdChannelNoisePulseCounter::RdChannelNoisePulseCounter::Run(), UnderGrdInjectorAG::UnderGrdInjector::Run(), RdMonitoring::RdMonitoring::Run(), RdChannelNoisePowerAnalyser::RdChannelNoisePowerAnalyser::Run(), Validatrix::Validatrix::Run(), io::TimeStamp_ROOT::Set(), un2::SimpleReco(), TestTime::TestConversions3(), TestTime::TestConversions5(), TestTime::TestTimeStampInitialization(), utl::UTCDateTime::UTCDateTime(), utlPython(), RdChannelBeaconTimingCalibrator::RdChannelBeaconTimingCalibrator::writeDebugFile(), and RdGlobalFit::RdGlobalFit::XmaxFromRmax().

static TimeStamp utl::TimeStamp::Max ( )
inlinestatic

Definition at line 177 of file TimeStamp.h.

References TimeStamp().

Referenced by TestTime::TestTimeConsistency().

utl::TimeStamp::operator bool ( ) const
inlineexplicit

Definition at line 175 of file TimeStamp.h.

References fGPSNanoSecond, and fGPSSecond.

bool utl::TimeStamp::operator!= ( const TimeStamp ts) const
inline

Definition at line 156 of file TimeStamp.h.

References operator==().

TimeStamp utl::TimeStamp::operator+ ( const TimeInterval ti) const
inline
TimeStamp & utl::TimeStamp::operator+= ( const TimeInterval ti)
inline
TimeInterval utl::TimeStamp::operator- ( const TimeStamp ts) const
inline

[TimeStamp] - [TimeStamp] = [TimeInterval]

Definition at line 232 of file TimeStamp.h.

References fGPSNanoSecond, fGPSSecond, utl::nanosecond, and utl::second.

TimeStamp utl::TimeStamp::operator- ( const TimeInterval ti) const
inline
TimeStamp & utl::TimeStamp::operator-= ( const TimeInterval ti)
inline
bool utl::TimeStamp::operator< ( const TimeStamp ts) const
inline

Definition at line 167 of file TimeStamp.h.

References fGPSNanoSecond, and fGPSSecond.

Referenced by operator>=().

bool utl::TimeStamp::operator<= ( const TimeStamp ts) const
inline

Definition at line 172 of file TimeStamp.h.

References operator>().

bool utl::TimeStamp::operator== ( const TimeStamp ts) const
inline

Definition at line 152 of file TimeStamp.h.

References fGPSNanoSecond, and fGPSSecond.

Referenced by operator!=().

bool utl::TimeStamp::operator> ( const TimeStamp ts) const
inline

Definition at line 159 of file TimeStamp.h.

References fGPSNanoSecond, and fGPSSecond.

Referenced by operator<=().

bool utl::TimeStamp::operator>= ( const TimeStamp ts) const
inline

Definition at line 164 of file TimeStamp.h.

References operator<().

void utl::TimeStamp::SetGPSTime ( const unsigned long  sec,
const double  nsec = 0 
)
inline
void utl::TimeStamp::SetNormalized ( long  sec,
double  nsec 
)
private

Take care of positive nanosecond and GPS epoch.

Definition at line 15 of file TimeStamp.cc.

References ERROR, utl::nanosecond, and galactic::second.

Referenced by operator+=(), operator-=(), SetGPSTime(), and TimeStamp().

Member Data Documentation

double utl::TimeStamp::fGPSNanoSecond
private
unsigned long utl::TimeStamp::fGPSSecond
private

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

, generated on Tue Sep 26 2023.