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>
Public Member Functions | |
CommonTime Basic Operations | |
CommonTime (TimeSystem timeSystem=TimeSystem::Unknown) | |
CommonTime (const CommonTime &right) | |
CommonTime & | operator= (const CommonTime &right) |
virtual | ~CommonTime () |
Destructor. More... | |
CommonTime Accessor Methods | |
CommonTime & | set (long day, long sod, double fsod=0.0, TimeSystem timeSystem=TimeSystem::Unknown) |
CommonTime & | set (long day, double sod=0.0, TimeSystem timeSystem=TimeSystem::Unknown) |
CommonTime & | set (double day, TimeSystem timeSys=TimeSystem::Unknown) |
CommonTime & | setInternal (long day=0, long msod=0, double fsod=0.0, TimeSystem timeSys=TimeSystem::Unknown) |
CommonTime & | setTimeSystem (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 |
CommonTime & | operator+= (double seconds) |
CommonTime & | operator-= (double seconds) |
CommonTime & | addSeconds (double seconds) |
CommonTime & | addDays (long days) |
CommonTime & | addSeconds (long seconds) |
CommonTime & | addMilliseconds (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< TimeSystemConverter > | tsConv |
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 () |
|
inlineexplicit |
Default Constructor. All numerical elements default to zero, "Unknown" for time frame.
Definition at line 120 of file CommonTime.hpp.
gnsstk::CommonTime::CommonTime | ( | const CommonTime & | right | ) |
Copy Constructor.
right | a const reference to the CommonTime object to copy. |
Definition at line 66 of file CommonTime.cpp.
|
inlinevirtual |
Destructor.
Definition at line 137 of file CommonTime.hpp.
|
inlineprotected |
Definition at line 410 of file CommonTime.hpp.
|
protected |
Add the following quantities to this CommonTime object.
days | the number of days to add |
msod | the number of milliseconds to add |
fsod | the number of fractional seconds to add |
Definition at line 455 of file CommonTime.cpp.
CommonTime & gnsstk::CommonTime::addDays | ( | long | days | ) |
Add integer days to this CommonTime object. param days the number of days to add to this CommonTime
InvalidRequest | on over-/under-flow |
Definition at line 365 of file CommonTime.cpp.
CommonTime & gnsstk::CommonTime::addMilliseconds | ( | long | ms | ) |
Add integer milliseconds to this CommonTime object.
ms | the number of milliseconds to add to this CommonTime |
InvalidRequest | on over-/under-flow |
Definition at line 371 of file CommonTime.cpp.
CommonTime & gnsstk::CommonTime::addSeconds | ( | double | seconds | ) |
Add seconds to this CommonTime object. This is the workhorse for the addition/subtraction operators.
seconds | the number of seconds to add to this CommonTime |
InvalidRequest | on over-/under-flow |
Definition at line 332 of file CommonTime.cpp.
CommonTime & gnsstk::CommonTime::addSeconds | ( | long | seconds | ) |
Add integer seconds to this CommonTime object.
seconds | the number of seconds to add to this CommonTime |
InvalidRequest | on over-/under-flow |
Definition at line 352 of file CommonTime.cpp.
std::string gnsstk::CommonTime::asString | ( | ) | const |
Definition at line 442 of file CommonTime.cpp.
bool gnsstk::CommonTime::changeTimeSystem | ( | TimeSystem | timeSystem | ) |
Modify both the time value and time system to reflect a change in time system.
[in] | timeSystem | The time system to convert this time to. |
Definition at line 204 of file CommonTime.cpp.
bool gnsstk::CommonTime::changeTimeSystem | ( | TimeSystem | timeSystem, |
TimeSystemConverter * | conv | ||
) |
Modify both the time value and time system to reflect a change in time system.
[in] | timeSystem | The time system to convert this time to. |
[in,out] | conv | The converter object to use to get the offset between the current time system and the requested time system. |
Definition at line 190 of file CommonTime.cpp.
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.
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.
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.
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.
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.
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.
double gnsstk::CommonTime::getDays | ( | ) | const |
Obtain the time, in days, including the fraction of a day.
Definition at line 271 of file CommonTime.cpp.
|
inline |
Get internal values method. Obtain the values stored within this object.
Definition at line 286 of file CommonTime.hpp.
|
inline |
Get internal values method. Obtain the values stored within this object.
Definition at line 275 of file CommonTime.hpp.
double gnsstk::CommonTime::getSecondOfDay | ( | ) | const |
Obtain the seconds of day (ignoring the day).
Definition at line 279 of file CommonTime.cpp.
TimeSystem gnsstk::CommonTime::getTimeSystem | ( | ) | const |
Obtain time system info (enum).
Definition at line 288 of file CommonTime.cpp.
|
protected |
Normalize the values. This takes out of bounds values and rolls other values appropriately.
Definition at line 466 of file CommonTime.cpp.
bool gnsstk::CommonTime::operator!= | ( | const CommonTime & | right | ) | const |
Definition at line 391 of file CommonTime.cpp.
CommonTime gnsstk::CommonTime::operator+ | ( | double | seconds | ) | const |
Add seconds to a copy of this CommonTime.
seconds | the number of seconds to add to a copy of this CommonTime |
InvalidRequest | on over-/under-flow |
Definition at line 310 of file CommonTime.cpp.
CommonTime & gnsstk::CommonTime::operator+= | ( | double | seconds | ) |
Add seconds to this CommonTime.
seconds | the number of seconds to add to this CommonTime. |
InvalidRequest | on over-/under-flow |
Definition at line 320 of file CommonTime.cpp.
double gnsstk::CommonTime::operator- | ( | const CommonTime & | right | ) | const |
Difference two Common Time objects.
right | CommonTime to subtract from this one |
Definition at line 293 of file CommonTime.cpp.
CommonTime gnsstk::CommonTime::operator- | ( | double | seconds | ) | const |
Subtract seconds from a copy of this CommonTime.
seconds | the number of seconds to subtract from a copy of this CommonTime |
InvalidRequest | on over-/under-flow |
Definition at line 315 of file CommonTime.cpp.
CommonTime & gnsstk::CommonTime::operator-= | ( | double | seconds | ) |
Subtract seconds from this CommonTime.
seconds | the number of seconds to subtract from this CommonTime |
InvalidRequest | on over-/under-flow |
Definition at line 326 of file CommonTime.cpp.
bool gnsstk::CommonTime::operator< | ( | const CommonTime & | right | ) | const |
Definition at line 396 of file CommonTime.cpp.
bool gnsstk::CommonTime::operator<= | ( | const CommonTime & | right | ) | const |
Definition at line 432 of file CommonTime.cpp.
CommonTime & gnsstk::CommonTime::operator= | ( | const CommonTime & | right | ) |
Assignment Operator.
right | a const reference to the CommonTime object to copy. |
Definition at line 71 of file CommonTime.cpp.
bool gnsstk::CommonTime::operator== | ( | const CommonTime & | right | ) | const |
Definition at line 377 of file CommonTime.cpp.
bool gnsstk::CommonTime::operator> | ( | const CommonTime & | right | ) | const |
Definition at line 427 of file CommonTime.cpp.
bool gnsstk::CommonTime::operator>= | ( | const CommonTime & | right | ) | const |
Definition at line 437 of file CommonTime.cpp.
|
inline |
Definition at line 399 of file CommonTime.hpp.
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.
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.
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.
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.
|
inline |
Set method for internal variable m_timeSystem.
Definition at line 195 of file CommonTime.hpp.
|
static |
'julian day' of earliest epoch expressible by CommonTime: 1/1/4713 B.C.E.
Definition at line 95 of file CommonTime.hpp.
|
static |
earliest representable CommonTime
Definition at line 102 of file CommonTime.hpp.
|
static |
'julian day' of latest epoch expressible by CommonTime: 1/1/4713 C.E.
Definition at line 99 of file CommonTime.hpp.
|
static |
latest representable CommonTime
Definition at line 104 of file CommonTime.hpp.
|
static |
Default tolerance for time equality in days.
Definition at line 107 of file CommonTime.hpp.
|
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.
|
protected |
fractional seconds-of-day 0 <= val < 0.001
Definition at line 439 of file CommonTime.hpp.
|
protected |
milliseconds-of-day 0 <= val < 86400000
Definition at line 438 of file CommonTime.hpp.
|
protected |
time frame (system representation) of the data
Definition at line 441 of file CommonTime.hpp.
|
static |
If set, this object will provide the ability for changeTimeSystem(TimeSystem) to function.
Definition at line 406 of file CommonTime.hpp.