00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef TNTDB_DATE_H
00030 #define TNTDB_DATE_H
00031
00032 #include <string>
00033
00034 namespace tntdb
00035 {
00039 class Date
00040 {
00041 unsigned short year;
00042 unsigned short month;
00043 unsigned short day;
00044
00045 public:
00047 Date()
00048 : year(0), month(0), day(0)
00049 { }
00050
00053 Date(unsigned short year_,
00054 unsigned short month_,
00055 unsigned short day_)
00056 : year(year_),
00057 month(month_),
00058 day(day_)
00059 { }
00060
00061 static Date localtime();
00062 static Date gmtime();
00063
00065 unsigned short getYear() const { return year; }
00067 unsigned short getMonth() const { return month; }
00069 unsigned short getDay() const { return day; }
00071 unsigned short getWDay() const;
00072
00073 bool isNull() const { return month == 0; }
00074
00076 void set(unsigned short year_,
00077 unsigned short month_,
00078 unsigned short day_)
00079 {
00080 year = year_;
00081 month = month_;
00082 day = day_;
00083 }
00084
00086 std::string getIso() const;
00089 static Date fromIso(const std::string& s);
00090
00091 bool operator== (const Date& dt) const
00092 { return year == dt.year
00093 && month == dt.month
00094 && day == dt.day; }
00095
00096 bool operator!= (const Date& dt) const
00097 { return !operator==(dt); }
00098
00099 bool operator< (const Date& dt) const
00100 {
00101 return year < dt.year ? true
00102 : year > dt.year ? false
00103 : month < dt.month ? true
00104 : month > dt.month ? false
00105 : day < dt.day;
00106 }
00107
00108 bool operator> (const Date& dt) const
00109 { return dt < *this; }
00110
00111 bool operator<= (const Date& dt) const
00112 { return !(*this > dt); }
00113
00114 bool operator>= (const Date& dt) const
00115 { return !(*this < dt); }
00116 };
00117 }
00118
00119 #endif // TNTDB_DATE_H
00120