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