DateTime.h++

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------
00002    commonc++ - A C++ Common Class Library
00003    Copyright (C) 2005-2012  Mark A Lindner
00004 
00005    This file is part of commonc++.
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Library General Public
00009    License as published by the Free Software Foundation; either
00010    version 2 of the License, or (at your option) any later version.
00011 
00012    This library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Library General Public License for more details.
00016 
00017    You should have received a copy of the GNU Library General Public
00018    License along with this library; if not, write to the Free
00019    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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 }; // namespace ccxx
00155 
00156 #endif // __ccxx_DateTime_hxx
00157 
00158 /* end of header file */
Generated on Sat Nov 26 16:49:07 2011 for libcommonc++ by  doxygen 1.6.3