DateTime.h++
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __ccxx_DateTime_hxx
00024 #define __ccxx_DateTime_hxx
00025
00026 #include <commonc++/Common.h++>
00027 #include <commonc++/Date.h++>
00028 #include <commonc++/String.h++>
00029 #include <commonc++/Time.h++>
00030 #include <commonc++/TimeSpan.h++>
00031
00032 namespace ccxx {
00033
00039 class COMMONCPP_API DateTime : public Date, public Time
00040 {
00041 public:
00042
00044 DateTime(time_s_t time) throw();
00045
00047 DateTime(time_ms_t time = 0) throw();
00048
00050 DateTime(uint_t day, uint_t month, uint_t year, uint_t hour = 0,
00051 uint_t minute = 0, uint_t second = 0, uint_t msec = 0) throw();
00052
00054 DateTime(const Date& date, const Time& time) throw();
00055
00057 DateTime(const Date& date) throw();
00058
00060 DateTime(const Time& time) throw();
00061
00063 DateTime(const DateTime& other) throw();
00064
00066 virtual ~DateTime() throw();
00067
00072 DateTime& normalize() throw();
00073
00075 operator time_s_t() const throw();
00076
00078 operator time_ms_t() const throw();
00079
00080 bool operator==(const DateTime& other) const throw();
00081 bool operator<(const DateTime& other) const throw();
00082 bool operator<=(const DateTime& other) const throw();
00083
00084 inline bool operator!=(const DateTime& other) const throw()
00085 { return(! operator==(other)); }
00086
00087 inline bool operator>(const DateTime& other) const throw()
00088 { return(! operator<=(other)); }
00089
00090 inline bool operator>=(const DateTime& other) const throw()
00091 { return(! operator<(other)); }
00092
00093 DateTime& operator=(time_s_t other) throw();
00094 DateTime& operator=(time_ms_t other) throw();
00095 DateTime& operator=(const DateTime& other) throw();
00096
00100 inline void setTime(uint_t hour, uint_t minute, uint_t second = 0,
00101 uint_t msec = 0) throw()
00102 { Time::setTime(hour, minute, second, msec); }
00103
00105 inline void setDate(uint_t day, uint_t month, uint_t year) throw()
00106 { Date::setDate(day, month, year); }
00107
00109 DateTime& setDate(const Date& other) throw();
00110
00112 DateTime& setTime(const Time& other) throw();
00113
00115 DateTime& operator+=(const TimeSpan& span) throw();
00116
00118 DateTime& operator-=(const TimeSpan& span) throw();
00119
00123 static bool isDSTActive() throw();
00124
00126 static int getGMTOffset() throw();
00127
00129 static String getTimeZone() throw();
00130 };
00131
00132 inline const TimeSpan operator-(const DateTime& d1, const DateTime& d2)
00133 throw()
00134 {
00135 time_ms_t t1 = d1;
00136 time_ms_t t2 = d2;
00137 return TimeSpan(t1 >= t2 ? t1 - t2 : t2 - t1);
00138 }
00139
00140 inline const DateTime operator-(const DateTime& d, const TimeSpan& ts)
00141 {
00142 DateTime tmp(d);
00143 tmp -= ts;
00144 return tmp;
00145 }
00146
00147 inline const DateTime operator+(const DateTime& d, const TimeSpan& ts)
00148 {
00149 DateTime tmp(d);
00150 tmp += ts;
00151 return tmp;
00152 }
00153
00154 };
00155
00156 #endif // __ccxx_DateTime_hxx
00157
00158