-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdatetime.h
111 lines (92 loc) · 3.18 KB
/
datetime.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// datetime.h
//
// date and time routines for GPS Processing
// This is a modfied version of the original routines created by
// Charles Schwarz and Gordon Adams. The functions were modified to
// use the Remondi Date/Time algorithms (see Hilla & Jackson (2000),
// The GPS Toolbox: The Remondi Date/Time Algorithms, GPS Solutions,
// 3(4), 71-74 ).
//
// DateTime provides the following formats for representing a GPS-time:
// 1. GPS time (GPS week and second of week)
// 2. Modified Julian Date (MJD and fraction-of-a-day)
// 3. Year, day-of-year, hour, minute, seconds
// 4. Year, Month, day, hour, minute, seconds
//
// An object of the class DateTime may be initialized (constructed) from
// any of the representations and viewed in any other representation.
//
#if !defined( DATETIME_ )
#define DATETIME_
#if !defined(IOSTREAM_)
#include <iostream>
#define IOSTREAM_
#endif
namespace NGSdatetime {
using std::ostream;
typedef struct{
long GPSWeek;
double secsOfWeek;
} GPSTime;
typedef struct{
long mjd;
double fracOfDay;
} MJD;
typedef struct{
long year;
long dayOfYear;
long hour;
long min;
double sec;
} YDOYHMS;
typedef struct{
long year;
long month;
long day;
long hour;
long min;
double sec;
} YMDHMS;
class DateTime
{
friend ostream &operator<<( ostream &output, DateTime &dt );
public:
// constructors
DateTime();
DateTime( GPSTime gpstime );
DateTime( MJD mjd );
DateTime( YDOYHMS yearDoyHMS );
DateTime( YMDHMS yearMonthDayHMS );
DateTime( long year, long month, long day,
long hour, long min, double sec );
// destructor
~DateTime();
// initializers
void SetGPSTime( GPSTime gpstime );
void SetMJD( MJD mjd );
void SetYDOYHMS( YDOYHMS yearDoyHMS );
void SetYMDHMS( YMDHMS yearMonthDayHMS );
void SetYMDHMS( long year, long month, long day,
long hour, long min, double sec );
// selectors
GPSTime GetGPSTime();
MJD GetMJD();
YDOYHMS GetYDOYHMS();
YMDHMS GetYMDHMS();
// manipulators
const DateTime &operator=(const DateTime &DT2);
DateTime* operator&(DateTime input);
DateTime operator + ( const double days );
double operator - ( const DateTime &DT2 );
bool operator == ( const DateTime &DT2 );
bool operator != ( const DateTime &DT2 );
bool operator > ( const DateTime &DT2 );
bool operator >= ( const DateTime &DT2 );
bool operator < ( const DateTime &DT2 );
bool operator <= ( const DateTime &DT2 );
private:
long mjd;
double fractionOfDay;
};
} // namespace NGSdatetime
#endif