#include <Epoch.hpp>
Collaboration diagram for Epoch:

Internally, the representation of day and time uses a CommonTime object.
The internal representation is manipulated using four fundamental routines, two that convert between 'jday' (the integer representation of JD) and calendar date: year/month/day-of-month, and two that convert between seconds-of-day and hour/minute/second. These routines can be found in the TimeConverters.hpp file. The range of validity of the jday--calendar routines is approximately 4317 B.C. to 4317 A.D.; these limits are incorporated into constants Epoch::BEGINNING_OF_TIME and Epoch::END_OF_TIME.
* All Epoch objects that lie outside these limits are disallowed. *
This representation separates day and time-of-day cleanly. Because day and time are logically separated, it is possible to use Epoch for day only, or for time only. Thus, for example, one could instantiate a Epoch object and only manipulate the date, without reference to time-of-day; or vice-versa. [However in this regard note that the default constructor for Epoch sets the data, not to zero, but to the current (system) time.]
When constructing Epoch objects from GPS time values -- such as GPS week and seconds of weeks, or GPS week and z count -- there may be ambiguity associated with the GPS week. Many receivers and receiver processing software store the GPS week as it appears in the NAV message, as a 10-bit number. This leads to a 1024 week ambiguity when 10-bit GPS weeks are used to specify a Epoch. In general, Epoch uses the system time to disambiguate which 1024 week period to use. This is a good assumption except when processing binary data from before GPS week rollover, which occured on August 22, 1999.
Definition at line 123 of file Epoch.hpp.
Tolerance Functions | |
| Epoch & | setTolerance (double tol) throw () |
| Sets the tolerance for output and comparisons on this object only. | |
| double | getTolerance () throw () |
| Return the tolerance value currently in use by this object. | |
| double | setEpochTolerance (double tol) throw () |
| Changes the EPOCH_TOLERANCE for all Epoch objects. | |
| double | getEpochTolerance () throw () |
| Returns the current EPOCH_TOLERANCE. | |
Public Member Functions | |
Constructors and Destructor | |
| Epoch (const TimeTag &tt=SystemTime()) throw (EpochException) | |
| Default Constructor. | |
| Epoch (const CommonTime &ct) throw () | |
| CommonTime Constructor. | |
| Epoch (const TimeTag &tt, short year) throw (EpochException) | |
| TimeTag + Year Constructor. | |
| Epoch (const GPSZcount &gzc) throw () | |
| GPSZcount Constructor. | |
| ~Epoch () throw () | |
| Destructor. | |
Assignment and Copy | |
| Epoch (const Epoch &right) throw () | |
| Copy constructor. | |
| Epoch & | operator= (const Epoch &right) throw () |
| Assignment operator. | |
Arithmetic | |
| double | operator- (const Epoch &right) const throw () |
| Epoch difference function. | |
| Epoch | operator+ (double sec) const throw (EpochException) |
| Add seconds to this time. | |
| Epoch | operator- (double sec) const throw (EpochException) |
| Subtract seconds from this time. | |
| Epoch & | operator+= (double sec) throw (EpochException) |
| Add seconds to this time. | |
| Epoch & | operator-= (double sec) throw (EpochException) |
| Subtract seconds from this time. | |
| Epoch & | addSeconds (double seconds) throw (EpochException) |
| Add (double) seconds to this time. | |
| Epoch & | addSeconds (long seconds) throw (EpochException) |
| Add (integer) seconds to this time. | |
| Epoch & | addMilliSeconds (long msec) throw (EpochException) |
| Add (integer) milliseconds to this time. | |
| Epoch & | addMicroSeconds (long usec) throw (EpochException) |
| Add (integer) microseconds to this time. | |
Comparisons | |
| bool | operator== (const Epoch &right) const throw () |
| bool | operator!= (const Epoch &right) const throw () |
| bool | operator< (const Epoch &right) const throw () |
| bool | operator> (const Epoch &right) const throw () |
| bool | operator<= (const Epoch &right) const throw () |
| bool | operator>= (const Epoch &right) const throw () |
Accessor Methods (get and set) | |
| template<class TimeTagType> | |
| TimeTagType | get () const throw (EpochException) |
| Get the specified TimeTag. | |
| long double | JD () const throw (EpochException) |
| Get Julian Date JD. | |
| long double | MJD () const throw (EpochException) |
| Get Modified Julian Date MJD. | |
| short | year () const throw (EpochException) |
| Get year. | |
| short | month () const throw (EpochException) |
| Get month of year. | |
| short | day () const throw (EpochException) |
| Get day of month. | |
| short | dow () const throw (EpochException) |
| Get day of week. | |
| short | hour () const throw (EpochException) |
| Get hour of day. | |
| short | minute () const throw (EpochException) |
| Get minutes of hour. | |
| double | second () const throw (EpochException) |
| Get seconds of minute. | |
| double | sod () const throw (EpochException) |
| Get seconds of day. | |
| short | GPSweek10 () const throw (EpochException) |
| Get 10-bit GPS week. | |
| long | GPSzcount () const throw (EpochException) |
| Get normal (19 bit) zcount. | |
| long | GPSzcountFloor () const throw (EpochException) |
| Same as GPSzcount() but without rounding to nearest zcount. | |
| unsigned long | GPSzcount32 () const throw (EpochException) |
| Get time as 32 bit Z count. | |
| unsigned long | GPSzcount32Floor () const throw (EpochException) |
| Same as fullZcount() but without rounding to nearest zcount. | |
| double | GPSsow () const throw (EpochException) |
| Get GPS second of week. | |
| short | GPSweek () const throw (EpochException) |
| Get full (>10 bits) week. | |
| short | doy () const throw (EpochException) |
| Get day of year. | |
| long double | getMJDasLongDouble () const throw (EpochException) |
| Get object time as a (long double) modified Julian date. | |
| timeval | unixTime () const throw (EpochException) |
| Get object time in UNIX timeval structure. | |
| operator GPSZcount () const throw (EpochException) | |
| Convert this object to a GPSZcount object. | |
| operator CommonTime () const throw () | |
| Convert this object to a CommonTime object. | |
| Epoch & | set (const TimeTag &tt=SystemTime()) throw (EpochException) |
| Set the object using a TimeTag object. | |
| Epoch & | set (const TimeTag &tt, short year) throw (EpochException) |
| Set the object using a TimeTag and a year as a hint. | |
| Epoch & | set (const CommonTime &c) throw () |
| Set the object using the give CommonTime. | |
| Epoch & | set (const GPSZcount &z) throw (EpochException) |
| Set the object using a GPSZcount object. | |
| Epoch & | setTime (const CommonTime &ct) throw (EpochException) |
| Set the object's time using a CommonTime object. | |
| Epoch & | setDate (const CommonTime &ct) throw (EpochException) |
| Set the object's date using a CommonTime object. | |
| Epoch & | setLocalTime () throw (EpochException) |
| Set the object time to the current local time. | |
Printing and Scanning Methods | |
| Epoch & | scanf (const std::string &str, const std::string &fmt) throw (StringUtils::StringException, InvalidRequest) |
| Similar to scanf, this function takes a string and a format describing string in order to read in values. | |
| std::string | printf (const std::string &fmt=PRINT_FORMAT) const throw (StringUtils::StringException) |
| Format this time into a string. | |
Static Public Attributes | |
Epoch-Specific Definitions | |
All of these tolerances are 1/2 of the tolerance they specify.
So one nsec tolerance is actually 1/2 an ns added to the time in units of days. | |
| const double | ONE_NSEC_TOLERANCE = 1e-9 |
| One nanosecond tolerance. | |
| const double | ONE_USEC_TOLERANCE = 1e-6 |
| One microsecond tolerance. | |
| const double | ONE_MSEC_TOLERANCE = 1e-3 |
| One millisecond tolerance. | |
| const double | ONE_SEC_TOLERANCE = 1 |
| One second tolerance. | |
| const double | ONE_MIN_TOLERANCE = 60 |
| One minute tolerance. | |
| const double | ONE_HOUR_TOLERANCE = 3600 |
| One hour tolerance. | |
| double | EPOCH_TOLERANCE = ONE_NSEC_TOLERANCE |
| Default tolerance for time equality in days. | |
| const Epoch | BEGINNING_OF_TIME |
| Earliest representable Epoch. | |
| const Epoch | END_OF_TIME |
| Latest Representable Epoch. | |
| std::string | PRINT_FORMAT |
| This is how an Epoch is printed by default. | |
|
|
Default Constructor. Initializes to current system time or to the given TimeTag. TimeTag-covered constructors: year, month, day, hour, minute, second (CivilTime) long double mjd (MJD) double mjd (MJD) year, doy, sod (YDSTime) Unix struct timeval (UnixTime) gps full week and second (GPSWeekSecond) |
|
|
CommonTime Constructor. Set the time using the given CommonTime object. |
|
||||||||||||
|
TimeTag + Year Constructor. Set the current time using the given year as a hint. For example, when one only knows the 10-bit GPS week, one could could use a "hint" year to figure out which Epoch the week was in. TimeTag + year -covered constructors: gps 10-bit week and second and year (GPSEpochWeekSecond + year) gps week and zcount and year (GPSWeekZcount + year) |
|
|
GPSZcount Constructor. Set the current time using the given GPSZcount. |
|
|
Destructor.
|
|
|
Copy constructor.
|
|
|
Add (integer) microseconds to this time.
Definition at line 259 of file Epoch.cpp. References CommonTime::addMilliseconds(), CommonTime::addSeconds(), and GPSTK_THROW. |
|
|
Add (integer) milliseconds to this time.
Definition at line 242 of file Epoch.cpp. References CommonTime::addMilliseconds(), and GPSTK_THROW. |
|
|
Add (integer) seconds to this time.
Definition at line 225 of file Epoch.cpp. References CommonTime::addSeconds(), and GPSTK_THROW. |
|
|
Add (double) seconds to this time.
Definition at line 208 of file Epoch.cpp. References CommonTime::addSeconds(), and GPSTK_THROW. Referenced by CommonTime::operator+(), and CommonTime::operator-(). |
|
|
Get day of month.
|
|
|
Get day of week.
|
|
|
Get day of year.
|
|
|
Get the specified TimeTag. This function converts the internal store into the requested TimeTag type. Definition at line 703 of file Epoch.hpp. Referenced by Epoch::GPSzcountFloor(). |
|
|
Returns the current EPOCH_TOLERANCE.
|
|
|
Get object time as a (long double) modified Julian date. For some compilers, this result may have diminished accuracy. |
|
|
Return the tolerance value currently in use by this object.
|
|
|
Get GPS second of week.
|
|
|
Get full (>10 bits) week.
|
|
|
Get 10-bit GPS week.
|
|
|
Get normal (19 bit) zcount.
|
|
|
Get time as 32 bit Z count. The 13 MSBs are week modulo 1024, 19 LSBs are seconds of week in Zcounts. |
|
|
Same as fullZcount() but without rounding to nearest zcount.
|
|
|
Same as GPSzcount() but without rounding to nearest zcount.
Definition at line 802 of file Epoch.hpp. References Epoch::get(). |
|
|
Get hour of day.
|
|
|
Get Julian Date JD.
|
|
|
Get minutes of hour.
|
|
|
Get Modified Julian Date MJD.
Definition at line 725 of file Epoch.hpp. Referenced by UTCTime::asTDB(). |
|
|
Get month of year.
|
|
|
Convert this object to a CommonTime object.
|
|
|
Convert this object to a GPSZcount object.
Definition at line 130 of file Epoch.cpp. References GPSTK_THROW, GPSWeek::week, and GPSWeekZcount::zcount. |
|
|
Definition at line 288 of file Epoch.cpp. References gpstk::operator==(). |
|
|
Add seconds to this time.
Definition at line 175 of file Epoch.cpp. References CommonTime::addSeconds(). |
|
|
Add seconds to this time.
|
|
|
Subtract seconds from this time.
Definition at line 184 of file Epoch.cpp. References CommonTime::addSeconds(). |
|
|
Epoch difference function.
|
|
|
Subtract seconds from this time.
|
|
|
Definition at line 295 of file Epoch.cpp. References gpstk::operator-(). |
|
|
Definition at line 311 of file Epoch.cpp. References gpstk::operator>(). |
|
|
Assignment operator.
Definition at line 155 of file Epoch.cpp. References Epoch::core. |
|
|
Definition at line 279 of file Epoch.cpp. References ABS. |
|
|
Definition at line 303 of file Epoch.cpp. References gpstk::operator-(). |
|
|
Definition at line 318 of file Epoch.cpp. References gpstk::operator<(). |
|
|
Format this time into a string.
fmt.
Definition at line 464 of file Epoch.cpp. References GPSTK_RETHROW, and gpstk::printTime(). Referenced by gpstk::operator<<(). |
|
||||||||||||
|
Similar to scanf, this function takes a string and a format describing string in order to read in values. The parameters it can take are listed below and described above with the printf() function. The specification must resolve to a day at a minimum level. The following table lists combinations that give valid times. Anything more or other combinations will give unknown (read as: "bad") results so don't try it. Anything less will throw an exception. If nothing changes the time of day, it will default to midnight. Also, the year defaults to the current year if a year isn't specified or can't be determined.
1 of... and 1 of.... optional... %C %G %w %g %Z %Y %y %F %w %g %Z %m %B %b %a %A %d %Y %y %H %M %S %Q %j %Y %y %s So time.setToString("Aug 1, 2000 20:20:20", "%b %d, %Y %H:%M:%S") time.setToString("Aug 2000", "%b %Y") Don't worry about counting whitespace - this function will take care of that. Just make sure that the extra stuff in the format string (ie '.' ',') are in the same relative location as they are in the actual string. (see in the example above))
Definition at line 448 of file Epoch.cpp. References GPSTK_RETHROW, and gpstk::scanTime(). |
|
|
Get seconds of minute.
|
|
|
Set the object using a GPSZcount object.
Definition at line 376 of file Epoch.cpp. References GPSTK_THROW, GPSWeek::week, and GPSWeekZcount::zcount. |
|
|
Set the object using the give CommonTime.
|
|
||||||||||||
|
Set the object using a TimeTag and a year as a hint.
Definition at line 345 of file Epoch.cpp. References GPSWeek::getWeek10(), GPSTK_THROW, and GPSWeek::setEpoch(). |
|
|
Set the object using a TimeTag object.
Definition at line 330 of file Epoch.cpp. References GPSTK_THROW. Referenced by Epoch::setLocalTime(). |
|
|
Set the object's date using a CommonTime object. This operation leaves the object's time unchanged.
Definition at line 413 of file Epoch.cpp. References GPSTK_THROW. |
|
|
Changes the EPOCH_TOLERANCE for all Epoch objects.
|
|
|
Set the object time to the current local time.
Definition at line 433 of file Epoch.cpp. References Epoch::set(). |
|
|
Set the object's time using a CommonTime object. This operation leaves the object's date unchanged.
Definition at line 394 of file Epoch.cpp. References GPSTK_THROW. |
|
|
Sets the tolerance for output and comparisons on this object only. See the constants in this file (e.g. ONE_NSEC_TOLERANCE) for some easy to use tolerance values.
|
|
|
Get seconds of day.
|
|
|
Get object time in UNIX timeval structure.
|
|
|
Get year.
|
|
|
Earliest representable Epoch.
|
|
|
Latest Representable Epoch.
|
|
|
Default tolerance for time equality in days.
|
|
|
One hour tolerance.
|
|
|
One minute tolerance.
|
|
|
One millisecond tolerance.
|
|
|
One nanosecond tolerance.
|
|
|
One second tolerance.
|
|
|
One microsecond tolerance.
|
|
|
This is how an Epoch is printed by default.
|
1.3.9.1