source: ntrip/trunk/BNC/src/bnctime.h@ 8822

Last change on this file since 8822 was 7669, checked in by stuerze, 9 years ago

minor changes

File size: 3.4 KB
Line 
1
2#ifndef BNCTIME_H
3#define BNCTIME_H
4
5#include <string>
6
7class bncTime {
8 public:
9 bncTime() {this->reset();}
10 bncTime(int gpsw, double gpssec);
11 bncTime(const std::string& isoString);
12
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 */
19 bncTime& set(int gpsw, double gpssec);
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);
22 bncTime& setmjd(double daysec, int mjd);
23 bncTime& setmjd(double mjddec);
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);
48
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 hour (0..59)
56 * @param sec second of minute (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 bncTime &setBDS(int gpsw, double gpssec);
61
62 void reset() {_mjd = 0; _sec = 0.0;}
63 unsigned int mjd() const;
64 double daysec() const;
65 /** Get GPS week.
66 * @return GPS week number
67 */
68 unsigned int gpsw() const;
69 /** Get Galileo week.
70 * @return Galileo week number
71 */
72 inline unsigned int galw() const { return gpsw()-1024; };
73 /** Get Seconds in GPS week.
74 * @return time of GPS week in seconds
75 */
76 double gpssec() const;
77 /** Get BDS/Beidou week.
78 * @return BDS week number
79 */
80 unsigned int bdsw() const;
81 /** Get Seconds in BDS/Beidou week.
82 * @return time of BDS week in seconds
83 */
84 double bdssec() const;
85 double mjddec() const {return (_mjd + _sec / 86400.0);}
86 void civil_date (unsigned int& year, unsigned int& month,
87 unsigned int& day) const;
88 void civil_time (unsigned int& hour, unsigned int& min,
89 double& sec) const;
90 bool valid() const {return _mjd != 0 || _sec != 0.0;}
91 bool undef() const {return !valid();}
92 bool operator==(const bncTime &time1) const;
93 bool operator!=(const bncTime &time1) const;
94 bool operator<(const bncTime &time1) const;
95 bool operator>(const bncTime &time1) const;
96 bool operator<=(const bncTime &time1) const;
97 bool operator>=(const bncTime &time1) const;
98 double operator-(const bncTime &time1) const;
99 bncTime operator-(double sec) const;
100 bncTime operator+(double sec) const;
101 bncTime& operator+=(double sec);
102
103 std::string timestr(unsigned numdec = 3, char sep = ':') const;
104 std::string datestr(char sep = '-') const;
105 operator std::string() const;
106
107 private:
108 unsigned int _mjd;
109 double _sec;
110};
111
112#endif
113
Note: See TracBrowser for help on using the repository browser.