Date.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_Date_hxx
00024 #define __ccxx_Date_hxx
00025 
00026 #include <commonc++/Common.h++>
00027 #include <commonc++/String.h++>
00028 
00029 namespace ccxx {
00030 
00036 class COMMONCPP_API Date
00037 {
00038   public:
00039 
00041   static const uint_t JAN;
00043   static const uint_t FEB;
00045   static const uint_t MAR;
00047   static const uint_t APR;
00049   static const uint_t MAY;
00051   static const uint_t JUN;
00053   static const uint_t JUL;
00055   static const uint_t AUG;
00057   static const uint_t SEP;
00059   static const uint_t OCT;
00061   static const uint_t NOV;
00063   static const uint_t DEC;
00064 
00065   enum Weekday { Invalid = 0, Monday, Tuesday, Wednesday, Thursday, Friday,
00066                  Saturday, Sunday };
00067 
00069   Date() throw();
00070 
00072   Date(uint_t day, uint_t month, uint_t year) throw();
00073 
00075   Date(const Date& other) throw();
00076 
00078   virtual ~Date() throw();
00079 
00081   void setMonth(uint_t month) throw();
00082 
00084   void setDay(uint_t day) throw();
00085 
00087   void setYear(uint_t year) throw();
00088 
00090   void setDate(uint_t day, uint_t month, uint_t year) throw();
00091 
00093   inline uint_t getMonth() const throw()
00094   { return(_month); }
00095 
00097   inline uint_t getDay() const throw()
00098   { return(_day); }
00099 
00101   inline uint_t getYear() const throw()
00102   { return(_year); }
00103 
00105   Weekday getWeekday() const throw();
00106 
00108   uint_t getDayOfYear() const throw();
00109 
00111   static bool isLeapYear(uint_t year) throw();
00112 
00116   uint_t getWeekOfYear() const throw();
00117 
00119   bool isValid() const throw();
00120 
00121   bool operator==(const Date& other) const throw();
00122   bool operator<(const Date& other) const throw();
00123   bool operator<=(const Date& other) const throw();
00124 
00125   inline bool operator!=(const Date& other) const throw()
00126   { return(! operator==(other)); }
00127 
00128   inline bool operator>(const Date& other) const throw()
00129   { return(! operator<=(other)); }
00130 
00131   inline bool operator>=(const Date& other) const throw()
00132   { return(! operator<(other)); }
00133 
00134   Date& operator=(const Date& other) throw();
00135 
00136   protected:
00137 
00139   uint_t _year;
00140   uint_t _month;
00141   uint_t _day;
00142   mutable Weekday _wday;
00143   mutable uint_t _yday;
00144   mutable int _wnum;
00147   private:
00148 
00149   void _recalculate() const;
00150 };
00151 
00152 }; // namespace ccxx
00153 
00154 #endif // __ccxx_Date_hxx
00155 
00156 /* end of header file */
Generated on Sat Nov 26 16:49:07 2011 for libcommonc++ by  doxygen 1.6.3