00001
00015 #ifndef _DLR_DATE_H_
00016 #define _DLR_DATE_H_
00017
00018 namespace dlr {
00019
00020 namespace utilities {
00021
00026 class Date {
00027 public:
00032 Date()
00033 : m_day(0), m_month(0), m_year(0) {}
00034
00035
00041 Date(const std::string& isoString) {this->setISODate(isoString);}
00042
00043
00053 Date(size_t year, size_t month, size_t day)
00054 : m_day(day), m_month(month), m_year(year) {this->sanitize();}
00055
00056
00062 Date(const Date& source)
00063 : m_day(source.m_day), m_month(source.m_month),
00064 m_year(source.m_year) {}
00065
00066
00070 ~Date() {}
00071
00072
00078 size_t
00079 day() const {return m_day;}
00080
00081
00087 size_t
00088 month() const {return m_month;}
00089
00090
00096 void
00097 setDay(size_t day) {m_day = day; this->sanitize();}
00098
00099
00105 void
00106 setISODate(const std::string& isoString);
00107
00108
00114 void
00115 setMonth(size_t month) {m_month = month; this->sanitize();}
00116
00117
00123 void
00124 setYear(size_t year) {m_year = year;}
00125
00126
00132 size_t
00133 year() const {return m_year;}
00134
00135 private:
00136
00137
00139 size_t
00140 dayCount(size_t month, size_t year);
00141
00142
00143 bool
00144 isLeapYear(size_t year);
00145
00147 void
00148 sanitize();
00149
00150
00151 size_t m_day;
00152 size_t m_month;
00153 size_t m_year;
00154 };
00155
00156
00167 bool
00168 operator<(const Date& date0, const Date& date1);
00169
00170
00181 bool
00182 operator>(const Date& date0, const Date& date1);
00183
00184
00195 bool
00196 operator<=(const Date& date0, const Date& date1);
00197
00198
00209 bool
00210 operator>=(const Date& date0, const Date& date1);
00211
00212
00223 bool
00224 operator==(const Date& date0, const Date& date1);
00225
00226
00237 bool
00238 operator!=(const Date& date0, const Date& date1);
00239
00240
00253 std::ostream&
00254 operator<<(std::ostream& stream, const Date& date);
00255
00256
00269 std::istream&
00270 operator>>(std::istream& stream, Date& date);
00271
00272 }
00273
00274 }
00275
00276
00277
00278
00279 namespace dlr {
00280
00281 using utilities::Date;
00282
00283 }
00284
00285
00286 #endif // #ifndef _DLR_DATE_H_