Time.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_Time_hxx
00024 #define __ccxx_Time_hxx
00025 
00026 #include <commonc++/Common.h++>
00027 #include <commonc++/String.h++>
00028 
00029 #include <ctime>
00030 
00031 namespace ccxx {
00032 
00038 class COMMONCPP_API Time
00039 {
00040   public:
00041 
00043   Time() throw();
00044 
00046   Time(uint_t hour, uint_t minute, uint_t second = 0, uint_t msec = 0)
00047     throw();
00048 
00050   Time(const Time& other) throw();
00051 
00053   virtual ~Time() throw();
00054 
00056   void setHour(uint_t hour) throw();
00057 
00059   void setHour12(uint_t hour, bool pm = false) throw();
00060 
00062   void setMinute(uint_t minute) throw();
00063 
00065   void setSecond(uint_t second) throw();
00066 
00068   void setMillisecond(uint_t msec) throw();
00069 
00073   void setTime(uint_t hour, uint_t minute, uint_t second = 0,
00074                uint_t msec = 0) throw();
00075 
00077   inline uint_t getHour() const throw()
00078   { return(_hour); }
00079 
00081   inline uint_t getHour12() const throw()
00082   { return(_hour == 0 ? 12 : _hour % 12); }
00083 
00085   inline bool isPM() const throw()
00086   { return(_hour >= 12); }
00087 
00089   inline bool isAM() const throw()
00090   { return(_hour < 12); }
00091 
00093   inline uint_t getMinute() const throw()
00094   { return(_minute); }
00095 
00097   inline uint_t getSecond() const throw()
00098   { return(_second); }
00099 
00101   inline uint_t getMillisecond() const throw()
00102   { return(_msec); }
00103 
00104   bool operator==(const Time& other) const throw();
00105   bool operator<(const Time& other) const throw();
00106   bool operator<=(const Time& other) const throw();
00107 
00108   inline bool operator!=(const Time& other) const throw()
00109   { return(! operator==(other)); }
00110 
00111   inline bool operator>(const Time& other) const throw()
00112   { return(! operator<=(other)); }
00113 
00114   inline bool operator>=(const Time& other) const throw()
00115   { return(! operator<(other)); }
00116 
00117   Time& operator=(const Time& other) throw();
00118 
00119   protected:
00120 
00122   uint_t _hour;
00123   uint_t _minute;
00124   uint_t _second;
00125   uint_t _msec;
00127 };
00128 
00129 }; // namespace ccxx
00130 
00131 #endif // __ccxx_Time_hxx
00132 
00133 /* end of header file */
Generated on Sat Nov 26 16:49:07 2011 for libcommonc++ by  doxygen 1.6.3