home *** CD-ROM | disk | FTP | other *** search
- #ifndef _ITIME_
- #define _ITIME_
- /*******************************************************************************
- * FILE NAME: itime.hpp *
- * *
- * DESCRIPTION: *
- * Declaration of the class(es): *
- * ITime - Class of objects representing time-of-day values *
- * *
- * COPYRIGHT: *
- * Licensed Materials - Property of IBM *
- * (C) Copyright IBM Corporation 1992, 1993 *
- * All Rights Reserved *
- * US Government Users Restricted Rights - Use, duplication, or disclosure *
- * restricted by GSA ADP Schedule Contract with IBM Corp. *
- * *
- *$Log: R:/IBMCLASS/IBASE/VCS/ITIME.HPV $ *
- //
- // Rev 1.2 25 Oct 1992 16:46:40 nunn
- //changed library name to ICLUI
-
- Rev 1.1 13 Oct 1992 09:58:14 law
- Removed virtual inheritance from IBase.
-
- Rev 1.0 08 Oct 1992 17:11:34 law
- Initial revision.
- *******************************************************************************/
- #ifndef _IBASE_
- #include <ibase.hpp>
- #endif
-
- #ifndef _ISTRING_
- #include <istring.hpp>
- #endif
-
- class ostream;
-
- class ITime : public IBase {
- /*******************************************************************************
- * Objects of this class represent units of time. These ITime objects *
- * represent portions of days (see also class IDate) and provide *
- * support for converting to hours, minutes, and seconds in numeric *
- * and ascii format. *
- * *
- * ITimes can be compared and operated on via addition/subtraction with *
- * other ITime objects. *
- *******************************************************************************/
- public:
- /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------------
- | There are four ways to construct ITime objects: |
- | |
- | 1. Using the default constructor, which returns the current |
- | time. |
- | |
- | 2. By giving the number of seconds (or the number of hours, |
- | minutes, and seconds) since midnight that the time is |
- | to represent; in the former case, the number of seconds |
- | may be negative and is subtracted from the number of |
- | seconds in a day |
- | |
- | 3. By using the static member function now() to return the |
- | current time. |
- | |
- | 4. By copying another ITime object. |
- ------------------------------------------------------------------------------*/
- ITime ( );
-
- ITime ( long seconds );
-
- ITime ( unsigned hours,
- unsigned minutes,
- unsigned seconds = 0 );
-
- ITime ( const ITime &aTime );
-
- static ITime
- now ( );
-
- /*-------------------------------- ACCESSORS -----------------------------------
- | These functions provide access to various portions of the |
- | representation of the ITime object: |
- | asSeconds - returns the number of seconds since midnight |
- | asString - returns the ITime as a string "hh:mm:ss" |
- | hours - returns the number of hours past midnight |
- | minutes - returns the number of minutes past the hour |
- | seconds - returns the number of seconds past the minute |
- ------------------------------------------------------------------------------*/
- long
- asSeconds ( ) const;
-
- IString
- asString ( ) const;
-
- unsigned
- hours ( ) const,
- minutes ( ) const,
- seconds ( ) const;
-
- /*-------------------------- COMPARISON OPERATORS ------------------------------
- | Two ITime objects can be compared, applying the intuitive logic. |
- ------------------------------------------------------------------------------*/
- Boolean
- operator == ( const ITime &aTime ) const,
- operator != ( const ITime &aTime ) const,
- operator < ( const ITime &aTime ) const,
- operator <= ( const ITime &aTime ) const,
- operator > ( const ITime &aTime ) const,
- operator >= ( const ITime &aTime ) const;
-
- /*------------------------- MANIPULATION OPERATORS -----------------------------
- | These operators permit two ITimes to be added or subtracted |
- | (via operator+ and operator-, respectively). The result can |
- | be placed back into the receiver (via operator+= and |
- | operator-=, respectively). |
- ------------------------------------------------------------------------------*/
- ITime
- operator + ( const ITime &aTime ) const,
- operator - ( const ITime &aTime ) const;
-
- ITime
- &operator += ( const ITime &aTime ),
- &operator -= ( const ITime &aTime );
-
- /*------------------------------- DISPLAYING -----------------------------------
- | ITimes can be output on an ostream using the conventional left-shift (<<) |
- | operator. |
- ------------------------------------------------------------------------------*/
- friend ostream
- &operator << ( ostream &aStream,
- const ITime &aTime );
-
- protected:
- /*----------------------------- IMPLEMENTATION ---------------------------------
- | These function are used to implement the ITime class: |
- | initialize - common initialization function used by ctors |
- ------------------------------------------------------------------------------*/
- ITime
- &initialize ( long seconds );
-
- private:
- /*--------------------------------- PRIVATE ----------------------------------*/
- long
- ticks;
-
- }; // ITime
-
- #endif /* _ITIME_ */