00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef TALOS_FILE_DATE_HXX
00021
00022
00023 namespace Talos
00024 {
00025
00027 class Date
00028 {
00029 private:
00031 int year_;
00033 int month_;
00035 int day_;
00037 int hour_;
00039 int minutes_;
00041 double seconds_;
00043 vector<int> month_lengths_;
00044
00045 void LeapYearAdjust();
00046 bool IsValid();
00047 void Adjust();
00048
00049 public:
00050 Date();
00051 Date(const Date& date);
00052 Date(string date);
00053 Date(int yyyymmdd);
00054 Date(int yyyy, int mm, int dd = 1,
00055 int hh = 0, int mn = 0, double sc = 0);
00056
00057 Date& operator=(const Date&);
00058 Date& operator=(string date);
00059 void SetDate(string date);
00060 void SetDate(int yyyymmdd);
00061 void SetDate(int yyyy, int mm, int dd = 1,
00062 int hh = 0, int mn = 0, double sc = 0);
00063
00064 bool LeapYear(int year) const;
00065 bool LeapYear() const;
00066
00067 int GetDate() const;
00068
00069 string GetDate(const string& format) const;
00070 template <class T>
00071 void GetDate(const string& format, T& date) const;
00072
00073 int GetYear() const;
00074 int GetMonth() const;
00075 int GetDay() const;
00076 int GetHour() const;
00077 int GetMinutes() const;
00078 double GetSeconds() const;
00079
00080 void AddYears(int nb_yy);
00081 void AddMonths(int nb_mm);
00082 void AddDays(int nb_dd);
00083 void AddHours(int nb_hh);
00084 void AddMinutes(int nb_mn);
00085 void AddSeconds(double nb_sc);
00086
00087 void SetYear(int yyyy);
00088 void SetMonth(int mm);
00089 void SetDay(int dd);
00090 void SetHour(int hh);
00091 void SetMinutes(int mn);
00092 void SetSeconds(double sc);
00093
00094 int GetOrdinalDay() const;
00095 int GetDayNumber() const;
00096 int GetNumberOfDays() const;
00097 int GetDaysFrom(Date date) const;
00098 double GetSecondsFrom(Date date) const;
00099
00100 int GetNumberOfHours() const;
00101 int GetNumberOfMinutes() const;
00102 double GetNumberOfSeconds() const;
00103
00104 int GetWeekDay() const;
00105 };
00106
00107
00108 bool operator < (const Date& first_date, const Date& second_date);
00109 bool operator <= (const Date& first_date, const Date& second_date);
00110 bool operator > (const Date& first_date, const Date& second_date);
00111 bool operator >= (const Date& first_date, const Date& second_date);
00112 bool operator == (const Date& first_date, const Date& second_date);
00113 bool operator != (const Date& first_date, const Date& second_date);
00114
00115
00116 ostream& operator << (ostream& out, const Date& d);
00117
00118 }
00119
00120
00121 #define TALOS_FILE_DATE_HXX
00122 #endif