List of all members
gnsstk::CommonTime Class Reference

Detailed Description

This is the common time format that all time formats convert to when converting between themselves. This allows the decoupling of inter-format conversions.

The interface is based on three quantites: days, seconds of day, and fractional seconds of day. The internal representation, however, is slightly different. It consists of a day, milliseconds of day, and fractional seconds of day. Their valid ranges are shown below:

Quantity >= <


day 0 2^31 msod 0 86400000 fsod 0 0.001

The above is somewhat difficult to grasp at first, but the reason for keeping the fractional part of time in units of seconds is due to the fact that the time formats usually break at seconds and partial seconds not at milliseconds and partial milliseconds. By keeping the value in seconds, we save ourselves additional work and loss of precision through conversion of fractional seconds to fractional milliseconds.

Definition at line 84 of file CommonTime.hpp.

#include <CommonTime.hpp>

Inheritance diagram for gnsstk::CommonTime:
Inheritance graph
[legend]

Public Member Functions

CommonTime Basic Operations
 CommonTime (TimeSystem timeSystem=TimeSystem::Unknown)
 
 CommonTime (const CommonTime &right)
 
CommonTimeoperator= (const CommonTime &right)
 
virtual ~CommonTime ()
 Destructor. More...
 
CommonTime Accessor Methods
CommonTimeset (long day, long sod, double fsod=0.0, TimeSystem timeSystem=TimeSystem::Unknown)
 
CommonTimeset (long day, double sod=0.0, TimeSystem timeSystem=TimeSystem::Unknown)
 
CommonTimeset (double day, TimeSystem timeSys=TimeSystem::Unknown)
 
CommonTimesetInternal (long day=0, long msod=0, double fsod=0.0, TimeSystem timeSys=TimeSystem::Unknown)
 
CommonTimesetTimeSystem (TimeSystem timeSystem)
 
bool changeTimeSystem (TimeSystem timeSystem, TimeSystemConverter *conv)
 
bool changeTimeSystem (TimeSystem timeSystem)
 
void get (long &day, long &sod, double &fsod, TimeSystem &timeSystem) const
 
void get (long &day, long &sod, double &fsod) const
 
void get (long &day, double &sod, TimeSystem &timeSystem) const
 
void get (long &day, double &sod) const
 
void get (double &day, TimeSystem &timeSystem) const
 
void get (double &day) const
 
void getInternal (long &day, long &msod, double &fsod, TimeSystem &timeSystem) const
 
void getInternal (long &day, long &msod, double &fsod) const
 
double getDays () const
 Obtain the time, in days, including the fraction of a day. More...
 
double getSecondOfDay () const
 Obtain the seconds of day (ignoring the day). More...
 
TimeSystem getTimeSystem () const
 Obtain time system info (enum). More...
 
CommonTime Arithmetic Operations
double operator- (const CommonTime &right) const
 
CommonTime operator+ (double seconds) const
 
CommonTime operator- (double seconds) const
 
CommonTimeoperator+= (double seconds)
 
CommonTimeoperator-= (double seconds)
 
CommonTimeaddSeconds (double seconds)
 
CommonTimeaddDays (long days)
 
CommonTimeaddSeconds (long seconds)
 
CommonTimeaddMilliseconds (long ms)
 

Static Public Attributes

CommonTime Constants
static const GNSSTK_EXPORT long BEGIN_LIMIT_JDAY = 0L
 
static const GNSSTK_EXPORT long END_LIMIT_JDAY = 3442448L
 
static const GNSSTK_EXPORT CommonTime BEGINNING_OF_TIME
 earliest representable CommonTime More...
 
static const GNSSTK_EXPORT CommonTime END_OF_TIME
 latest representable CommonTime More...
 
static const GNSSTK_EXPORT double eps = 4.*std::numeric_limits<double>::epsilon()
 Default tolerance for time equality in days. More...
 

CommonTime Comparison Operators

All comparison operators have a parameter "right" which corresponds to the CommonTime object to the right of the symbol. All comparison operators are const and return true on success and false on failure.

static GNSSTK_EXPORT std::shared_ptr< TimeSystemConvertertsConv
 
long m_day
 
long m_msod
 milliseconds-of-day 0 <= val < 86400000 More...
 
double m_fsod
 fractional seconds-of-day 0 <= val < 0.001 More...
 
TimeSystem m_timeSystem
 time frame (system representation) of the data More...
 
bool operator== (const CommonTime &right) const
 
bool operator!= (const CommonTime &right) const
 
bool operator< (const CommonTime &right) const
 
bool operator> (const CommonTime &right) const
 
bool operator<= (const CommonTime &right) const
 
bool operator>= (const CommonTime &right) const
 
void reset ()
 
std::string asString () const
 
 CommonTime (long day, long sod, double fsod, TimeSystem timeSystem=TimeSystem::Unknown)
 
bool add (long days, long msod, double fsod)
 
bool normalize ()
 

Constructor & Destructor Documentation

◆ CommonTime() [1/3]

gnsstk::CommonTime::CommonTime ( TimeSystem  timeSystem = TimeSystem::Unknown)
inlineexplicit

Default Constructor. All numerical elements default to zero, "Unknown" for time frame.

See also
CommonTime::set()

Definition at line 120 of file CommonTime.hpp.

◆ CommonTime() [2/3]

gnsstk::CommonTime::CommonTime ( const CommonTime right)

Copy Constructor.

Parameters
righta const reference to the CommonTime object to copy.

Definition at line 66 of file CommonTime.cpp.

◆ ~CommonTime()

virtual gnsstk::CommonTime::~CommonTime ( )
inlinevirtual

Destructor.

Definition at line 137 of file CommonTime.hpp.

◆ CommonTime() [3/3]

gnsstk::CommonTime::CommonTime ( long  day,
long  sod,
double  fsod,
TimeSystem  timeSystem = TimeSystem::Unknown 
)
inlineprotected

Definition at line 410 of file CommonTime.hpp.

Member Function Documentation

◆ add()

bool gnsstk::CommonTime::add ( long  days,
long  msod,
double  fsod 
)
protected

Add the following quantities to this CommonTime object.

Parameters
daysthe number of days to add
msodthe number of milliseconds to add
fsodthe number of fractional seconds to add
Returns
the result of calling the normalize() function

Definition at line 455 of file CommonTime.cpp.

◆ addDays()

CommonTime & gnsstk::CommonTime::addDays ( long  days)

Add integer days to this CommonTime object. param days the number of days to add to this CommonTime

Returns
a reference to this CommonTime object
Exceptions
InvalidRequeston over-/under-flow

Definition at line 365 of file CommonTime.cpp.

◆ addMilliseconds()

CommonTime & gnsstk::CommonTime::addMilliseconds ( long  ms)

Add integer milliseconds to this CommonTime object.

Parameters
msthe number of milliseconds to add to this CommonTime
Returns
a reference to this CommonTime object
Exceptions
InvalidRequeston over-/under-flow

Definition at line 371 of file CommonTime.cpp.

◆ addSeconds() [1/2]

CommonTime & gnsstk::CommonTime::addSeconds ( double  seconds)

Add seconds to this CommonTime object. This is the workhorse for the addition/subtraction operators.

Parameters
secondsthe number of seconds to add to this CommonTime
Returns
a reference to this CommonTime object
Exceptions
InvalidRequeston over-/under-flow

Definition at line 332 of file CommonTime.cpp.

◆ addSeconds() [2/2]

CommonTime & gnsstk::CommonTime::addSeconds ( long  seconds)

Add integer seconds to this CommonTime object.

Parameters
secondsthe number of seconds to add to this CommonTime
Returns
a reference to this CommonTime object
Exceptions
InvalidRequeston over-/under-flow

Definition at line 352 of file CommonTime.cpp.

◆ asString()

std::string gnsstk::CommonTime::asString ( ) const

Definition at line 442 of file CommonTime.cpp.

◆ changeTimeSystem() [1/2]

bool gnsstk::CommonTime::changeTimeSystem ( TimeSystem  timeSystem)

Modify both the time value and time system to reflect a change in time system.

Parameters
[in]timeSystemThe time system to convert this time to.
Returns
true if successful, false if the static converter tsConv has not been set or is unable to get/apply the time system offset.

Definition at line 204 of file CommonTime.cpp.

◆ changeTimeSystem() [2/2]

bool gnsstk::CommonTime::changeTimeSystem ( TimeSystem  timeSystem,
TimeSystemConverter conv 
)

Modify both the time value and time system to reflect a change in time system.

Parameters
[in]timeSystemThe time system to convert this time to.
[in,out]convThe converter object to use to get the offset between the current time system and the requested time system.
Returns
true if successful, false if unable to get/apply the time system offset.

Definition at line 190 of file CommonTime.cpp.

◆ get() [1/6]

void gnsstk::CommonTime::get ( double &  day) const

Get method through which one may obtain a value for day which includes the fraction of a day.

Definition at line 264 of file CommonTime.cpp.

◆ get() [2/6]

void gnsstk::CommonTime::get ( double &  day,
TimeSystem timeSystem 
) const

Get method through which one may obtain a value for day which includes the fraction of a day, plus the time frame.

Definition at line 253 of file CommonTime.cpp.

◆ get() [3/6]

void gnsstk::CommonTime::get ( long &  day,
double &  sod 
) const

Get method through which one may obtain values for day and second of day which includes the fractional second of day.

Definition at line 245 of file CommonTime.cpp.

◆ get() [4/6]

void gnsstk::CommonTime::get ( long &  day,
double &  sod,
TimeSystem timeSystem 
) const

Get method through which one may obtain values for day and second of day which includes the fractional second of day, plus the time frame.

Definition at line 235 of file CommonTime.cpp.

◆ get() [5/6]

void gnsstk::CommonTime::get ( long &  day,
long &  sod,
double &  fsod 
) const

Get method. Obtain values in days, second of day and fractional second of day.

Definition at line 226 of file CommonTime.cpp.

◆ get() [6/6]

void gnsstk::CommonTime::get ( long &  day,
long &  sod,
double &  fsod,
TimeSystem timeSystem 
) const

Get method. Obtain values in days, second of day and fractional second of day, plus the time frame.

Definition at line 213 of file CommonTime.cpp.

◆ getDays()

double gnsstk::CommonTime::getDays ( ) const

Obtain the time, in days, including the fraction of a day.

Definition at line 271 of file CommonTime.cpp.

◆ getInternal() [1/2]

void gnsstk::CommonTime::getInternal ( long &  day,
long &  msod,
double &  fsod 
) const
inline

Get internal values method. Obtain the values stored within this object.

Definition at line 286 of file CommonTime.hpp.

◆ getInternal() [2/2]

void gnsstk::CommonTime::getInternal ( long &  day,
long &  msod,
double &  fsod,
TimeSystem timeSystem 
) const
inline

Get internal values method. Obtain the values stored within this object.

Definition at line 275 of file CommonTime.hpp.

◆ getSecondOfDay()

double gnsstk::CommonTime::getSecondOfDay ( ) const

Obtain the seconds of day (ignoring the day).

Definition at line 279 of file CommonTime.cpp.

◆ getTimeSystem()

TimeSystem gnsstk::CommonTime::getTimeSystem ( ) const

Obtain time system info (enum).

Definition at line 288 of file CommonTime.cpp.

◆ normalize()

bool gnsstk::CommonTime::normalize ( )
protected

Normalize the values. This takes out of bounds values and rolls other values appropriately.

Returns
true if m_day is valid, false otherwise

Definition at line 466 of file CommonTime.cpp.

◆ operator!=()

bool gnsstk::CommonTime::operator!= ( const CommonTime right) const

Definition at line 391 of file CommonTime.cpp.

◆ operator+()

CommonTime gnsstk::CommonTime::operator+ ( double  seconds) const

Add seconds to a copy of this CommonTime.

Parameters
secondsthe number of seconds to add to a copy of this CommonTime
Returns
the new CommonTime object
Exceptions
InvalidRequeston over-/under-flow

Definition at line 310 of file CommonTime.cpp.

◆ operator+=()

CommonTime & gnsstk::CommonTime::operator+= ( double  seconds)

Add seconds to this CommonTime.

Parameters
secondsthe number of seconds to add to this CommonTime.
Returns
a reference to this CommonTime
Exceptions
InvalidRequeston over-/under-flow

Definition at line 320 of file CommonTime.cpp.

◆ operator-() [1/2]

double gnsstk::CommonTime::operator- ( const CommonTime right) const

Difference two Common Time objects.

Parameters
rightCommonTime to subtract from this one
Returns
the difference in seconds

Definition at line 293 of file CommonTime.cpp.

◆ operator-() [2/2]

CommonTime gnsstk::CommonTime::operator- ( double  seconds) const

Subtract seconds from a copy of this CommonTime.

Parameters
secondsthe number of seconds to subtract from a copy of this CommonTime
Returns
the new CommonTime object
Exceptions
InvalidRequeston over-/under-flow

Definition at line 315 of file CommonTime.cpp.

◆ operator-=()

CommonTime & gnsstk::CommonTime::operator-= ( double  seconds)

Subtract seconds from this CommonTime.

Parameters
secondsthe number of seconds to subtract from this CommonTime
Returns
a reference to this CommonTime object
Exceptions
InvalidRequeston over-/under-flow

Definition at line 326 of file CommonTime.cpp.

◆ operator<()

bool gnsstk::CommonTime::operator< ( const CommonTime right) const

Definition at line 396 of file CommonTime.cpp.

◆ operator<=()

bool gnsstk::CommonTime::operator<= ( const CommonTime right) const

Definition at line 432 of file CommonTime.cpp.

◆ operator=()

CommonTime & gnsstk::CommonTime::operator= ( const CommonTime right)

Assignment Operator.

Parameters
righta const reference to the CommonTime object to copy.
Returns
a reference to this CommonTime object.

Definition at line 71 of file CommonTime.cpp.

◆ operator==()

bool gnsstk::CommonTime::operator== ( const CommonTime right) const

Definition at line 377 of file CommonTime.cpp.

◆ operator>()

bool gnsstk::CommonTime::operator> ( const CommonTime right) const

Definition at line 427 of file CommonTime.cpp.

◆ operator>=()

bool gnsstk::CommonTime::operator>= ( const CommonTime right) const

Definition at line 437 of file CommonTime.cpp.

◆ reset()

void gnsstk::CommonTime::reset ( )
inline

Definition at line 399 of file CommonTime.hpp.

◆ set() [1/3]

CommonTime & gnsstk::CommonTime::set ( double  day,
TimeSystem  timeSys = TimeSystem::Unknown 
)

Set method that accepts a value for day. It also checks the validity of the argument and throws an exception if its value is out of bounds.

Definition at line 143 of file CommonTime.cpp.

◆ set() [2/3]

CommonTime & gnsstk::CommonTime::set ( long  day,
double  sod = 0.0,
TimeSystem  timeSystem = TimeSystem::Unknown 
)

Set method that accepts values for day and seconds of day. It also checks the validity of the arguments and throws an exception if any values are out of bounds.

Definition at line 131 of file CommonTime.cpp.

◆ set() [3/3]

CommonTime & gnsstk::CommonTime::set ( long  day,
long  sod,
double  fsod = 0.0,
TimeSystem  timeSystem = TimeSystem::Unknown 
)

Set method that accepts values for day, seconds of day and fractional seconds of day. It also checks the validity of the arguments and throws an exception if any values are out of bounds.

Definition at line 87 of file CommonTime.cpp.

◆ setInternal()

CommonTime & gnsstk::CommonTime::setInternal ( long  day = 0,
long  msod = 0,
double  fsod = 0.0,
TimeSystem  timeSys = TimeSystem::Unknown 
)

Set internal values method. Set the data members of this object directly. Checks the validity of the given time representation and throws an exception if any values are out of bounds.

Definition at line 153 of file CommonTime.cpp.

◆ setTimeSystem()

CommonTime& gnsstk::CommonTime::setTimeSystem ( TimeSystem  timeSystem)
inline

Set method for internal variable m_timeSystem.

Definition at line 195 of file CommonTime.hpp.

Member Data Documentation

◆ BEGIN_LIMIT_JDAY

const long gnsstk::CommonTime::BEGIN_LIMIT_JDAY = 0L
static

'julian day' of earliest epoch expressible by CommonTime: 1/1/4713 B.C.E.

See also
m_day.

Definition at line 95 of file CommonTime.hpp.

◆ BEGINNING_OF_TIME

const CommonTime gnsstk::CommonTime::BEGINNING_OF_TIME
static

earliest representable CommonTime

Definition at line 102 of file CommonTime.hpp.

◆ END_LIMIT_JDAY

const long gnsstk::CommonTime::END_LIMIT_JDAY = 3442448L
static

'julian day' of latest epoch expressible by CommonTime: 1/1/4713 C.E.

See also
m_day.

Definition at line 99 of file CommonTime.hpp.

◆ END_OF_TIME

const CommonTime gnsstk::CommonTime::END_OF_TIME
static

latest representable CommonTime

Definition at line 104 of file CommonTime.hpp.

◆ eps

const double gnsstk::CommonTime::eps = 4.*std::numeric_limits<double>::epsilon()
static

Default tolerance for time equality in days.

Definition at line 107 of file CommonTime.hpp.

◆ m_day

long gnsstk::CommonTime::m_day
protected

Days since midnight -4713/01/01. This is similar to, but not a true Julian Day as it starts at midnight instead of noon. The time stamp is defined this way so as to avoid having to make half-day offsets every time we convert to or from CommonTime.

Definition at line 437 of file CommonTime.hpp.

◆ m_fsod

double gnsstk::CommonTime::m_fsod
protected

fractional seconds-of-day 0 <= val < 0.001

Definition at line 439 of file CommonTime.hpp.

◆ m_msod

long gnsstk::CommonTime::m_msod
protected

milliseconds-of-day 0 <= val < 86400000

Definition at line 438 of file CommonTime.hpp.

◆ m_timeSystem

TimeSystem gnsstk::CommonTime::m_timeSystem
protected

time frame (system representation) of the data

Definition at line 441 of file CommonTime.hpp.

◆ tsConv

std::shared_ptr< TimeSystemConverter > gnsstk::CommonTime::tsConv
static

If set, this object will provide the ability for changeTimeSystem(TimeSystem) to function.

Definition at line 406 of file CommonTime.hpp.


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


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:44