1 |
|
---|
2 | #ifndef TIME_H
|
---|
3 | #define TIME_H
|
---|
4 |
|
---|
5 | #include <string>
|
---|
6 |
|
---|
7 | class t_time {
|
---|
8 | public:
|
---|
9 | static double djul(long j1, long m1, double tt);
|
---|
10 | static double gpjd(double second, int nweek) ;
|
---|
11 | static void jdgp(double tjul, double & second, long & nweek);
|
---|
12 | static void jmt (double djul, long& jj, long& mm, double& dd);
|
---|
13 |
|
---|
14 | t_time() {this->reset();}
|
---|
15 | t_time(int gpsw, int dow, double daysec);
|
---|
16 | t_time(int gpsw, double gpssec);
|
---|
17 | t_time(int hour, int min, double sec, int day, int month, int year);
|
---|
18 | t_time(double daysec, int day, int month, int year);
|
---|
19 | t_time(double daysec, int doy, unsigned int year);
|
---|
20 |
|
---|
21 | void reset() {_mjd = 0; _sec = 0;}
|
---|
22 | bool undef() const {return (_mjd==0 && _sec==0);}
|
---|
23 | bool valid() const {return (_mjd!=0 || _sec!=0);}
|
---|
24 |
|
---|
25 | t_time & operator++();
|
---|
26 | t_time operator++(int);
|
---|
27 |
|
---|
28 | t_time & operator--();
|
---|
29 | t_time operator--(int);
|
---|
30 |
|
---|
31 | t_time operator+(double sec) const;
|
---|
32 | t_time operator-(double sec) const;
|
---|
33 |
|
---|
34 | t_time& operator+=(double sec);
|
---|
35 | t_time& operator-=(double sec);
|
---|
36 |
|
---|
37 | double operator-(const t_time &time1) const;
|
---|
38 |
|
---|
39 | bool operator< (const t_time &time1) const;
|
---|
40 | bool operator<=(const t_time &time1) const;
|
---|
41 | bool operator> (const t_time &time1) const;
|
---|
42 | bool operator>=(const t_time &time1) const;
|
---|
43 | bool operator==(const t_time &time1) const;
|
---|
44 | bool operator!=(const t_time &time1) const;
|
---|
45 |
|
---|
46 | unsigned int gpsw() const;
|
---|
47 | unsigned int dow() const;
|
---|
48 | double daysec() const;
|
---|
49 | double gpssec() const;
|
---|
50 |
|
---|
51 | unsigned int doy() const;
|
---|
52 | unsigned int mjd() const;
|
---|
53 | double mjddec() const;
|
---|
54 |
|
---|
55 | unsigned int year() const;
|
---|
56 | unsigned int month() const;
|
---|
57 | unsigned int day() const;
|
---|
58 | unsigned int hour() const;
|
---|
59 | unsigned int minute() const;
|
---|
60 | double sec() const;
|
---|
61 |
|
---|
62 | void civil_datum(unsigned int& year,
|
---|
63 | unsigned int& month, unsigned int& day) const;
|
---|
64 | void civil_time (unsigned int& hour, unsigned int& min, double& sec) const;
|
---|
65 | void civil_datum(int& year,
|
---|
66 | int& month, int& day) const;
|
---|
67 | void civil_time (int& hour, int& min, double& sec) const;
|
---|
68 |
|
---|
69 | t_time& set(int gpsw, int dow, double daysec);
|
---|
70 | t_time& set(int gpsw, double gpssec);
|
---|
71 | t_time& set(int hour, int min, double sec, int day, int month, int year);
|
---|
72 | t_time& set(double daysec, int day, int month, int year);
|
---|
73 | t_time& set(double daysec, int doy, int year);
|
---|
74 | t_time& setmjd(double daysec, int mjd);
|
---|
75 | t_time& setmjd(double mjddec);
|
---|
76 |
|
---|
77 | t_time& setmachinetime(bool gmt = false);
|
---|
78 |
|
---|
79 | operator std::string() const;
|
---|
80 | std::string datestr(bool digit2year = false, char sep = '-') const;
|
---|
81 | std::string timestr(unsigned numdec = 3, char sep = ':') const;
|
---|
82 |
|
---|
83 | private:
|
---|
84 | unsigned int _mjd;
|
---|
85 | double _sec;
|
---|
86 | };
|
---|
87 |
|
---|
88 | #endif
|
---|
89 |
|
---|