Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

simpletime.h

Go to the documentation of this file.
00001 /********************************************************************
00002        Copyright (c) 2001, Lee Patterson & Ant Works Software
00003        http://ssobjects.sourceforge.net
00004 
00005        Original source from http://www.codeproject.com/datetime/dateclass.asp
00006        Copyright (c), Richard Stringer
00007        
00008        Original source copyright got lost. 
00009 
00010        filename :  simpletime.h
00011        author   :  Lee Patterson (lee@antws.com)
00012 *********************************************************************/
00013 
00014 #ifndef SIMPLETIME_H
00015 #define SIMPLETIME_H
00016 
00017 namespace ssobjects
00018 {
00019 
00020 typedef const char* PTIMESTRING;
00021 
00022 #define SECS_PER_MIN 60
00023 #define SECS_PER_HOUR 3600
00024 #define SECS_PER_DAY (86400)    //SECSperHOUR*24
00025 
00026 class CSimpleTime
00027 {
00028   public:     //attributes
00029     unsigned    m_currentTime;      //current time of this day in seconds
00030     unsigned    m_hour;
00031     unsigned    m_minute;
00032     unsigned    m_second;
00033     char        m_szFormated[80];
00034 
00035   public:     //construction
00036     CSimpleTime();
00037     CSimpleTime(const char* szTime);
00038     CSimpleTime(unsigned seconds);
00039 
00040   protected:  //methods
00041     void FormatOutput();
00042     void SetTime();
00043         
00044         
00045   public:     //methods
00046     static unsigned GetCurrentTime();
00047     static unsigned Convert(unsigned hour,unsigned minute,unsigned second);
00048     static bool     IsValid(unsigned time) {return time < SECS_PER_DAY ? true:false;}
00049 
00050     virtual unsigned GetHour();
00051     virtual unsigned GetMinute();
00052     virtual unsigned GetSecond();
00053 
00054 //        operator long() const {return m_currentTime;}
00055     operator unsigned() const {return m_currentTime;}
00056     operator PTIMESTRING();
00057 
00058     CSimpleTime& operator = (const char* time);
00059     CSimpleTime& operator = (const unsigned time);
00060 
00061     //lee: I changed this to return by value instead of ref. g++ gave a warning. not tested yet
00062     CSimpleTime operator += (const unsigned time);
00063     CSimpleTime operator -= (const unsigned time);
00064 
00065     bool operator == (const unsigned time) const;
00066     bool operator < (const unsigned time) const;
00067     bool operator > (const unsigned time) const;
00068     bool operator <= (const unsigned time) const;
00069     bool operator >= (const unsigned time) const;
00070 
00071     bool operator == (const CSimpleTime& time) const;
00072     bool operator < (const CSimpleTime& time) const;
00073     bool operator > (const CSimpleTime& time) const;
00074     bool operator <= (const CSimpleTime& time) const;
00075     bool operator >= (const CSimpleTime& time) const;
00076 };
00077 
00078 };
00079 
00080 #endif

Generated on Thu Nov 8 12:39:26 2001 for SimpleServerObjects by doxygen1.2.11 written by Dimitri van Heesch, © 1997-2001