CommonTime Class Reference

#include <CommonTime.hpp>

Inheritance diagram for CommonTime:

Inheritance graph
[legend]
Collaboration diagram for CommonTime:

Collaboration graph
[legend]
List of all members.

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 71 of file CommonTime.hpp.

Public Member Functions

 CommonTime (TimeSystem timeSystem=TimeSystem::Unknown) throw ( InvalidParameter )
 Default Constructor.
 CommonTime (const CommonTime &right) throw ()
 Copy Constructor.
CommonTimeoperator= (const CommonTime &right) throw ()
 Assignment Operator.
virtual ~CommonTime () throw ()
 Destructor.
CommonTimeset (long day, long sod, double fsod=0.0, TimeSystem timeSystem=TimeSystem::Unknown) throw ( InvalidParameter )
 Set method that accepts values for day, seconds of day and fractional seconds of day.
CommonTimeset (long day, double sod=0.0, TimeSystem timeSystem=TimeSystem::Unknown) throw ( InvalidParameter )
 Set method that accepts values for day and seconds of day.
CommonTimeset (double day, TimeSystem timeSys=TimeSystem::Unknown) throw ( InvalidParameter )
 Set method that accepts a value for day.
CommonTimesetInternal (long day=0, long msod=0, double fsod=0.0, TimeSystem timeSys=TimeSystem::Unknown) throw ( InvalidParameter )
 Set internal values method.
void setTimeSystem (const TimeSystem &timeSystem) throw ()
 Set method for internal variable m_timeSystem.
void get (long &day, long &sod, double &fsod, TimeSystem &timeSystem) const throw ()
 Get method.
void get (long &day, long &sod, double &fsod) const throw ()
 Get method.
void get (long &day, double &sod, TimeSystem &timeSystem) const throw ()
 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.
void get (long &day, double &sod) const throw ()
 Get method through which one may obtain values for day and second of day which includes the fractional second of day.
void get (double &day, TimeSystem &timeSystem) const throw ()
 Get method through which one may obtain a value for day which includes the fraction of a day, plus the time frame.
void get (double &day) const throw ()
 Get method through which one may obtain a value for day which includes the fraction of a day.
void getInternal (long &day, long &msod, double &fsod, TimeSystem &timeSystem) const throw ()
 Get internal values method.
void getInternal (long &day, long &msod, double &fsod) const throw ()
 Get internal values method.
double getDays () const throw ()
 Obtain the time, in days, including the fraction of a day.
double getSecondOfDay () const throw ()
 Obtain the seconds of day (ignoring the day).
TimeSystem getTimeSystem () const throw ()
 Obtain time system info (enum).
double operator- (const CommonTime &right) const throw ( InvalidRequest )
 Difference two Common Time objects.
CommonTime operator+ (double seconds) const throw ()
 Add seconds to a copy of this CommonTime.
CommonTime operator- (double seconds) const throw ()
 Subtract seconds from a copy of this CommonTime.
CommonTimeoperator+= (double seconds) throw ()
 Add seconds to this CommonTime.
CommonTimeoperator-= (double seconds) throw ()
 Subtract seconds from this CommonTime.
CommonTimeaddSeconds (double seconds) throw ()
 Add seconds to this CommonTime object.
CommonTimeaddDays (long days) throw ()
 Add integer days to this CommonTime object.
CommonTimeaddSeconds (long seconds) throw ()
 Add integer seconds to this CommonTime object.
CommonTimeaddMilliseconds (long ms) throw ()
 Add integer milliseconds to this CommonTime object.
bool operator== (const CommonTime &right) const throw ()
bool operator!= (const CommonTime &right) const throw ()
bool operator< (const CommonTime &right) const throw ( InvalidRequest )
bool operator> (const CommonTime &right) const throw ( InvalidRequest )
bool operator<= (const CommonTime &right) const throw ( InvalidRequest )
bool operator>= (const CommonTime &right) const throw ( InvalidRequest )
void reset () throw ()
std::string asString () const throw ()

Static Public Attributes

const long BEGIN_LIMIT_JDAY = 0L
 'julian day' of earliest epoch expressible by CommonTime: 1/1/4713 B.C.
const long END_LIMIT_JDAY = 3442448L
 'julian day' of latest epoch expressible by CommonTime: 1/1/4713 A.D.
const CommonTime BEGINNING_OF_TIME
 earliest representable CommonTime
const CommonTime END_OF_TIME
 latest representable CommonTime
const double eps = 4.*std::numeric_limits<double>::epsilon()
 Default tolerance for time equality, applied to milliseconds.

Protected Member Functions

 CommonTime (long day, long sod, double fsod, TimeSystem timeSystem=TimeSystem::Unknown) throw ( InvalidParameter )
bool add (long days, long msod, double fsod) throw ()
 protected functions
bool normalize () throw ()
 Normalize the values.

Protected Attributes

long m_day
 days (as a Julian Day) 0 <= val < 2^31
long m_msod
 milliseconds-of-day 0 <= val < 86400000
double m_fsod
 fractional seconds-of-day 0 <= val < 0.001
TimeSystem m_timeSystem
 time frame (system representation) of the data


Constructor & Destructor Documentation

CommonTime long  day,
long  sod,
double  fsod,
TimeSystem  timeSystem = TimeSystem::Unknown
throw ( InvalidParameter ) [inline, protected]
 

Definition at line 389 of file CommonTime.hpp.


Member Function Documentation

bool add long  days,
long  msod,
double  fsod
throw () [protected]
 

protected functions

Parameters:
days the number of days to add
msod the number of milliseconds to add
fsod the number of fractional seconds to add
Returns:
the result of calling the normalize() function

Definition at line 440 of file CommonTime.cpp.

References gpstk::normalize().

std::string asString  )  const throw ()
 

Definition at line 426 of file CommonTime.cpp.

References TimeSystem::asString(), CommonTime::m_day, CommonTime::m_fsod, CommonTime::m_msod, and CommonTime::m_timeSystem.

Referenced by gpstk::operator<<(), and Rinex3ClockHeader::ParseHeaderRecord().

bool normalize  )  throw () [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 452 of file CommonTime.cpp.

References ABS, CommonTime::m_day, CommonTime::m_fsod, CommonTime::m_msod, and gpstk::SEC_PER_MS.

void reset void   )  throw () [inline]
 

Definition at line 380 of file CommonTime.hpp.


Member Data Documentation

long m_day [protected]
 

days (as a Julian Day) 0 <= val < 2^31

Definition at line 414 of file CommonTime.hpp.

Referenced by CommonTime::asString(), and CommonTime::normalize().

double m_fsod [protected]
 

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

Definition at line 416 of file CommonTime.hpp.

Referenced by CommonTime::asString(), and CommonTime::normalize().

long m_msod [protected]
 

milliseconds-of-day 0 <= val < 86400000

Definition at line 415 of file CommonTime.hpp.

Referenced by CommonTime::asString(), and CommonTime::normalize().

TimeSystem m_timeSystem [protected]
 

time frame (system representation) of the data

Definition at line 418 of file CommonTime.hpp.

Referenced by CommonTime::asString().


The documentation for this class was generated from the following files:
Generated on Sat May 18 03:31:43 2013 for GPS ToolKit Software Library by  doxygen 1.3.9.1