📄 daytime.hpp
字号:
* UNIX time constructor. * @param t timeval structure (typically from gettimeofday()). * @param f Time frame (see #TimeFrame) */ DayTime(const struct timeval& t, TimeFrame f = Unknown) throw(DayTimeException); /// Destructor. ~DayTime() throw() {} // --------- Part 4: member functions: assignment and copy ---------- // /// Copy constructor. DayTime(const DayTime &right) throw(DayTimeException); /// Assignment operator. DayTime& operator=(const DayTime& right) throw(); // ----------- Part 5: member functions: arithmetic ------------ // /** * DayTime difference function. * @param right DayTime to subtract from this one. * @return difference in seconds. */ double operator-(const DayTime& right) const throw(); /** * Add seconds to this time. * @param sec Number of seconds to increase this time by. * @return The new time incremented by \c sec. */ DayTime operator+(double sec) const throw(); /** * Subtract seconds from this time. * @param sec Number of seconds to decrease this time by. * @return The new time decremented by \c sec. */ DayTime operator-(double sec) const throw(); /** * Add seconds to this time. * @param sec Number of seconds to increase this time by. * @throws DayTimeException on over/under-flow */ DayTime& operator+=(double sec) throw(DayTimeException); /** * Subtract seconds from this time. * @param sec Number of seconds to decrease this time by. * @throws DayTimeException on over/under-flow */ DayTime& operator-=(double sec) throw(DayTimeException); /** * Add (double) seconds to this time. * @param seconds Number of seconds to increase this time by. * @throws DayTimeException on over/under-flow */ DayTime& addSeconds(double seconds) throw(DayTimeException); /** * Add (integer) seconds to this time. * @param seconds Number of seconds to increase this time by. * @throws DayTimeException on over/under-flow */ DayTime& addSeconds(long seconds) throw(DayTimeException); /** * Add (integer) milliseconds to this time. * @param msec Number of milliseconds to increase this time by. * @throws DayTimeException on over/under-flow */ DayTime& addMilliSeconds(long msec) throw(DayTimeException); /** * Add (integer) microseconds to this time. * @param usec Number of microseconds to increase this time by. * @throws DayTimeException on over/under-flow */ DayTime& addMicroSeconds(long usec) throw(DayTimeException); // ----------- Part 6: member functions: comparisons ------------ // /// Equality operator. /// @return true if ABS(*this - right) <= lesser of tolerance /// and right.tolerance; false otherwise bool operator==(const DayTime &right) const throw(); /// Inequality operator. bool operator!=(const DayTime &right) const throw(); /// Comparison operator (less-than). bool operator<(const DayTime &right) const throw(); /// Comparison operator (greater-than). bool operator>(const DayTime &right) const throw(); /// Comparison operator (less-than or equal-to). bool operator<=(const DayTime &right) const throw(); /// Comparison operator (greater-than or equal-to). bool operator>=(const DayTime &right) const throw(); // ----------- Part 7: member functions: time frame ------------ // /** * Change time frames via pseudo-copy method. * Copies all of \c right except the time frame, * which remains unchanged. * @param right DayTime object to copy time from. * @throws DayTimeException */ DayTime& setAllButTimeFrame(const DayTime& right) throw(DayTimeException); /// Set the time frame for this time. DayTime& setTimeFrame(TimeFrame f) throw() { timeFrame = f ; return *this ; } /// Get the time frame for this time. TimeFrame getTimeFrame() const throw() { return timeFrame ; } // ----------- Part 8: member functions: get -------------- // // These routines retrieve elements of day, time or both. // /// Get Julian Date JD double JD() const throw(); /// Get Modified Julian Date MJD /// @warning For some compilers, this result may have diminished /// accuracy. double MJD() const throw(); /// Get year. short year() const throw(); /// Get month of year. short month() const throw(); /// Get day of month. short day() const throw(); /// Get day of week short dayOfWeek() const throw(); /// Get year, month and day of month void getYMD(int& yy, int& mm, int& dd) const throw() { convertJDtoCalendar(jday, yy, mm, dd) ; } /// Get hour of day. short hour() const throw(); /// Get minutes of hour. short minute() const throw(); /// Get seconds of minute. double second() const throw(); /// Get seconds of day. double secOfDay() const throw() { return (double(mSod) + mSec) / FACTOR ; } /// Get 10-bit GPS week. short GPS10bitweek() const throw(); /// Get normal (19 bit) zcount. long GPSzcount() const throw(); /// Same as GPSzcount() but without rounding to nearest zcount. long GPSzcountFloor() const throw(); /// Get seconds of week. double GPSsecond() const throw() { return GPSsow(); } /// Get GPS second of week. double GPSsow() const throw(); /// Get day of week. short GPSday() const throw() { return dayOfWeek(); } /// Get full (>10 bits) week short GPSfullweek() const throw(); /// Get year. short GPSyear() const throw() { return year(); } /// Get year. short DOYyear() const throw() { return year(); } /// Get day of year. short DOYday() const throw() { return DOY(); } /// Get day of year. short DOY() const throw(); /// Get seconds of day. double DOYsecond() const throw() { return secOfDay(); } /// Get object time as a modified Julian date. /// @warning For some compilers, this result may have diminished /// accuracy. double MJDdate() const throw() { return double(getMJDasLongDouble()) ; } /// Get object time as a (long double) modified Julian date. /// @Warning For some compilers, this result may have diminished /// accuracy. long double getMJDasLongDouble() const throw(); /// Get object time in UNIX timeval structure. struct timeval unixTime() const throw(DayTimeException); /** * Get time as 32 bit Z count. * The 13 MSBs are week modulo 1024, 19 LSBs are seconds of * week in Zcounts. */ unsigned long fullZcount() const throw(); /// Same as fullZcount() but without rounding to nearest zcount. unsigned long fullZcountFloor() const throw(); /// Convert this object to a GPSZcount object. /// @throws DayTimeException if this DayTime's current state /// doesn't constitute a valid GPS Z-count. operator GPSZcount() const throw(DayTimeException) ; /// Convert this object to a CommonTime object. /// @throws DayTimeException if this DayTime's current state /// doesn't constitute a valid CommonTime. operator CommonTime() const throw(DayTimeException); // ----------- Part 9: member functions: set ------------ // /** * Set the object's time using calendar (Y/M/D) date * and ordinary (H:M:S) time * @param year four-digit year. * @param month month of year (1-based). * @param day day of month (1-based). * @param hour hour of day. * @param min minutes of hour. * @param sec seconds of minute. * @param f Time frame (see #TimeFrame) * @return a reference to this object. */ DayTime& setYMDHMS(short year, short month, short day, short hour, short min, double sec, TimeFrame f = Unknown) throw(DayTimeException); /** * Set the object's time using GPS time. * @warn In the case of 10-bit week input, the number of * GPS week rollovers, and therefore the full GPS week, * is determined from the current system time. * @param week GPS week number. * @param sow GPS seconds of week. * @param f Time frame (see #TimeFrame) * @return a reference to this object. */ DayTime& setGPS(short week, double sow, TimeFrame f = Unknown) throw(DayTimeException); /** * Set the object's time using GPS time (week and Z count). * @warn In the case of 10-bit week input, the number of * GPS week rollovers, and therefore the full GPS week, * is determined from the current system time; prefer setGPSfullweek(). * @param week GPS week number. * @param zcount Z-count (seconds of week / 1.5) * @param f Time frame (see #TimeFrame) * @return a reference to this object. */ DayTime& setGPS(short week, long zcount, TimeFrame f = Unknown) throw(DayTimeException); /** * Set the object's time using GPS time. In case of 10-bit * week input, the year and week are used to deduce the number * of GPS week rollovers and thus the full GPS week; * prefer setGPSfullweek(). * @param week GPS week number. * @param zcount GPS Z-count (seconds of week / 1.5) * @param year Four-digit year consistent with GPS input. * @param f Time frame (see #TimeFrame) * @return a reference to this object. */ DayTime& setGPS(short week, long zcount, short year, TimeFrame f = Unknown) throw(DayTimeException); /** * Set the object's time using GPS time. In case of 10-bit * week input, the year and week are used to deduce the number * of GPS week rollovers and thus the full GPS week; * prefer setGPSfullweek(). * @param week GPS week number. * @param sow GPS seconds of week. * @param year Four-digit year consistent with GPS input. * @param f Time frame (see #TimeFrame) * @return a reference to this object. */ DayTime& setGPS(short week, double sow, short year, TimeFrame f = Unknown) throw(DayTimeException); /** * Set the object's time using GPS time (full Z count). * @warn The number of GPS week rollovers, and therefore the * full GPS week, is determined from the current system time. * @param Zcount Full z-count (3 MSB unused, mid 10 bits - * week number, 19 LSB "normal" z-count). * @param f Time frame (see #TimeFrame) * @return a reference to this object. */ DayTime& setGPS(unsigned long Zcount, TimeFrame f = Unknown) throw(DayTimeException); /** * Set the object's time using GPS time. * @param fullweek Full (i.e. >10bits) GPS week number. * @param sow Seconds of week. * @param f Time frame (see #TimeFrame) * @return a reference to this object. */ DayTime& setGPSfullweek(short fullweek, double sow, TimeFrame f = Unknown) throw(DayTimeException); /** * Set the object's time using GPS time. * @param fullweek Full (i.e. >10bits) GPS week number. * @param zcount Z-count (seconds of week / 1.5) * @param f Time frame (see #TimeFrame)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -