[2123] | 1 |
|
---|
| 2 | #ifndef BNCTIME_H
|
---|
| 3 | #define BNCTIME_H
|
---|
| 4 |
|
---|
| 5 | #include <string>
|
---|
| 6 |
|
---|
| 7 | class bncTime {
|
---|
| 8 | public:
|
---|
| 9 | bncTime() {this->reset();}
|
---|
| 10 | bncTime(int gpsw, double gpssec);
|
---|
[3986] | 11 | bncTime(const std::string& isoString);
|
---|
[2123] | 12 |
|
---|
[6812] | 13 | /**
|
---|
| 14 | * Set GPS time.
|
---|
| 15 | * @param gpsw GPS week
|
---|
| 16 | * @param gpssec GPS time of week in seconds
|
---|
| 17 | * @return reference to current instance
|
---|
| 18 | */
|
---|
[2123] | 19 | bncTime& set(int gpsw, double gpssec);
|
---|
[2251] | 20 | bncTime& set(int year, int month, int day, int hour, int min, double sec);
|
---|
| 21 | bncTime& set(int year, int month, int day, double daysec);
|
---|
[3507] | 22 | bncTime& setmjd(double daysec, int mjd);
|
---|
[4586] | 23 | bncTime& setmjd(double mjddec);
|
---|
[6812] | 24 | /**
|
---|
| 25 | * Set GPS time relative to current time.
|
---|
| 26 | * @param msec milliseconds of GPS week
|
---|
| 27 | * @return reference to current instance
|
---|
| 28 | */
|
---|
| 29 | bncTime &set(int msec);
|
---|
| 30 | /**
|
---|
| 31 | * Set GPS time relative to current time.
|
---|
| 32 | * @param msec milliseconds of current GPS day
|
---|
| 33 | * @return reference to current instance
|
---|
| 34 | */
|
---|
| 35 | bncTime &setTOD(int msec);
|
---|
| 36 | /**
|
---|
| 37 | * Set GLONASS time relative to current time.
|
---|
| 38 | * @param msec milliseconds of GLONASS day
|
---|
| 39 | * @return reference to current instance
|
---|
| 40 | */
|
---|
| 41 | bncTime &setTk(int msec);
|
---|
| 42 | /**
|
---|
| 43 | * Set BDS time relative to current time.
|
---|
| 44 | * @param msec milliseconds of BDS week
|
---|
| 45 | * @return reference to current instance
|
---|
| 46 | */
|
---|
| 47 | bncTime &setBDS(int msec);
|
---|
[2123] | 48 |
|
---|
[6812] | 49 | /**
|
---|
| 50 | * Set BDS time.
|
---|
| 51 | * @param year 4 digit year
|
---|
| 52 | * @param month month in year (1..12)
|
---|
| 53 | * @param day day of month (1..31)
|
---|
| 54 | * @param hour hour of day (0..23)
|
---|
| 55 | * @param min minute of hopur (0..59)
|
---|
| 56 | * @param sec second of minutte (0..59,60)
|
---|
| 57 | * @return reference to current instance
|
---|
| 58 | */
|
---|
| 59 | bncTime &setBDS (int year, int month, int day, int hour, int min, double sec);
|
---|
| 60 |
|
---|
[3752] | 61 | void reset() {_mjd = 0; _sec = 0;}
|
---|
[2123] | 62 | unsigned int mjd() const;
|
---|
| 63 | double daysec() const;
|
---|
[6812] | 64 | /** Get GPS week.
|
---|
| 65 | * @return GPS week number
|
---|
| 66 | */
|
---|
[2123] | 67 | unsigned int gpsw() const;
|
---|
[6812] | 68 | /** Get Seconds in GPS week.
|
---|
| 69 | * @return time of GPS week in seconds
|
---|
| 70 | */
|
---|
[2123] | 71 | double gpssec() const;
|
---|
[6812] | 72 | /** Get BDS/Beidou week.
|
---|
| 73 | * @return BDS week number
|
---|
| 74 | */
|
---|
| 75 | unsigned int bdsw() const;
|
---|
| 76 | /** Get Seconds in BDS/Beidou week.
|
---|
| 77 | * @return time of BDS week in seconds
|
---|
| 78 | */
|
---|
| 79 | double bdssec() const;
|
---|
[4584] | 80 | double mjddec() const {return (_mjd + _sec / 86400.0);}
|
---|
[2566] | 81 | void civil_date (unsigned int& year, unsigned int& month,
|
---|
| 82 | unsigned int& day) const;
|
---|
[2177] | 83 | void civil_time (unsigned int& hour, unsigned int& min,
|
---|
| 84 | double& sec) const;
|
---|
[2809] | 85 | bool valid() const {return _mjd != 0 || _sec != 0.0;}
|
---|
[5742] | 86 | bool undef() const {return !valid();}
|
---|
[2917] | 87 | bool operator==(const bncTime &time1) const;
|
---|
[2809] | 88 | bool operator!=(const bncTime &time1) const;
|
---|
[2923] | 89 | bool operator<(const bncTime &time1) const;
|
---|
| 90 | bool operator>(const bncTime &time1) const;
|
---|
| 91 | bool operator<=(const bncTime &time1) const;
|
---|
| 92 | bool operator>=(const bncTime &time1) const;
|
---|
[2809] | 93 | double operator-(const bncTime &time1) const;
|
---|
| 94 | bncTime operator-(double sec) const;
|
---|
| 95 | bncTime operator+(double sec) const;
|
---|
[5742] | 96 | bncTime& operator+=(double sec);
|
---|
[2123] | 97 |
|
---|
| 98 | std::string timestr(unsigned numdec = 3, char sep = ':') const;
|
---|
[2566] | 99 | std::string datestr(char sep = '-') const;
|
---|
[5742] | 100 | operator std::string() const;
|
---|
[2123] | 101 |
|
---|
| 102 | private:
|
---|
| 103 | unsigned int _mjd;
|
---|
| 104 | double _sec;
|
---|
| 105 | };
|
---|
| 106 |
|
---|
| 107 | #endif
|
---|
| 108 |
|
---|