CARMA C++
Date.h
1 #ifndef SZA_UTIL_DATE_H
2 #define SZA_UTIL_DATE_H
3 
11 #include <string>
12 
13 namespace sza {
14  namespace util {
15 
16  class Date {
17  public:
18 
22  Date();
23  Date(Date& date);
24  Date(Date* date);
25  Date(const Date& date);
26  Date(std::string date);
27  Date(int day, std::string month, int year);
28  Date(double mjd);
29 
30  void initialize(unsigned day, std::string month, int year);
31 
35  virtual ~Date();
36 
37  static double calToMjd(int iy, int im, int id);
38  static double calToMjd(unsigned day, std::string month, int year);
39  static double calToMjd(int iy, int im, int id, int hour, int min, int sec);
40 
41  static std::string mjdToCal(double mjd);
42  std::string mjdToCal();
43 
44  static std::string mjdToArcCal(double mjd);
45  std::string mjdToArcCal();
46 
47  static std::string mjdToHorizonsCal(double mjd);
48  std::string mjdToHorizonsCal();
49 
50  static void mjdToCalDate(double mjd,
51  unsigned& year, unsigned& month, unsigned& day);
52 
53  static std::string mjdToBuildTime(double mjd);
54  static std::string mjdToBuildDate(double mjd);
55 
56  double getMjd() {
57  return mjd_;
58  }
59 
60  unsigned year();
61  std::string month();
62  unsigned day();
63 
64  void setTo(std::string date);
65  void setTo(std::string date, std::string time);
66  void setToDateAndTime(std::string dateAndTime);
67 
68  // Assignment operator
69 
70  void operator=(std::string start);
71 
72  bool operator>(Date& date);
73  bool operator>=(Date& date);
74  bool operator<(Date& date);
75  bool operator<(const Date& date);
76  bool operator<=(Date& date);
77  bool operator==(Date& date);
78  Date operator-(double days);
79  Date operator-(Date& days);
80  Date operator+(double days);
81  void operator+=(double days);
82 
83  friend std::ostream& operator<<(std::ostream& os, Date& date);
84  friend std::ostream& operator<<(std::ostream& os, const Date& date);
85 
86  static int deltaDays(Date& date1, Date& date2);
87 
88  static const char* months[];
89 
90  void addDays(double days);
91  void addHours(double hours);
92 
93  unsigned numberOfDays();
94 
95  bool isEmpty();
96 
97  unsigned dayInYear();
98 
99  double mjd() {
100  return mjd_;
101  }
102 
103  private:
104 
105  double mjd_;
106 
107  static void slaDjcal(int ndp, double djm, int iymdf[4]);
108  static void slaDjcl(double djm, int* iy, int* im, int* id, double* df, int* status);
109  static void slaClyd(int iy, int im, int id, int *ny, int *nd, int *jstat );
110 
111  static unsigned validateMonth(std::string month);
112  static unsigned validateDay(unsigned day, std::string month);
113  static int validateYear(int year);
114 
115  }; // End class Date
116 
117  } // End namespace util
118 } // End namespace sza
119 
120 #endif // End #ifndef SZA_UTIL_DATE_H
121