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 #include <iostream>
00024 #include <algorithm>
00025 #include <string>
00026 #include <fstream>
00027 #include <sstream>
00028 #include <vector>
00029 #include <stdexcept>
00030
00031
00032 namespace Talos
00033 {
00034
00035 using namespace std;
00036
00038 class Date
00039 {
00040 private:
00042 int year_;
00044 int month_;
00046 int day_;
00048 int hour_;
00050 int minutes_;
00052 double seconds_;
00054 vector<int> month_lengths_;
00055
00056 void LeapYearAdjust();
00057 bool IsValid();
00058 void Adjust();
00059
00060 public:
00061 Date();
00062 Date(const Date& date);
00063 Date(string date);
00064 Date(int yyyymmdd);
00065 Date(int yyyy, int mm, int dd = 1,
00066 int hh = 0, int mn = 0, double sc = 0);
00067
00068 #ifndef SWIG
00069 Date& operator=(const Date&);
00070 Date& operator=(string date);
00071 #endif
00072 void SetDate(string date);
00073 void SetDate(int yyyymmdd);
00074 void SetDate(int yyyy, int mm, int dd = 1,
00075 int hh = 0, int mn = 0, double sc = 0);
00076
00077 bool LeapYear(int year) const;
00078 bool LeapYear() const;
00079
00080 int GetDate() const;
00081
00082 string GetDate(const string& format) const;
00083 template <class T>
00084 void GetDate(const string& format, T& date) const;
00085
00086 int GetYear() const;
00087 int GetMonth() const;
00088 int GetDay() const;
00089 int GetHour() const;
00090 int GetMinutes() const;
00091 double GetSeconds() const;
00092
00093 void AddYears(int nb_yy);
00094 void AddMonths(int nb_mm);
00095 void AddDays(int nb_dd);
00096 void AddHours(int nb_hh);
00097 void AddMinutes(int nb_mn);
00098 void AddSeconds(double nb_sc);
00099
00100 void SetYear(int yyyy);
00101 void SetMonth(int mm);
00102 void SetDay(int dd);
00103 void SetHour(int hh);
00104 void SetMinutes(int mn);
00105 void SetSeconds(double sc);
00106
00107 int GetOrdinalDay() const;
00108 int GetDayNumber() const;
00109 int GetNumberOfDays() const;
00110 int GetDaysFrom(Date date) const;
00111 double GetSecondsFrom(Date date) const;
00112
00113 int GetNumberOfHours() const;
00114 int GetNumberOfMinutes() const;
00115 double GetNumberOfSeconds() const;
00116
00117 int GetWeekDay() const;
00118 };
00119
00120
00121 bool operator < (const Date& first_date, const Date& second_date);
00122 bool operator <= (const Date& first_date, const Date& second_date);
00123 bool operator > (const Date& first_date, const Date& second_date);
00124 bool operator >= (const Date& first_date, const Date& second_date);
00125 bool operator == (const Date& first_date, const Date& second_date);
00126 bool operator != (const Date& first_date, const Date& second_date);
00127
00128 #ifndef SWIG
00129
00130 ostream& operator << (ostream& out, const Date& d);
00131 #endif
00132
00133 }
00134
00135
00136 #define TALOS_FILE_DATE_HXX
00137 #endif