home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / Dloads / OTHERUTI / TCPP30-1.ZIP / CLASSSRC.ZIP / LTIME.CPP < prev    next >
C/C++ Source or Header  |  1992-02-18  |  2KB  |  67 lines

  1. /*------------------------------------------------------------------------*/
  2. /*                                                                        */
  3. /*  LTIME.CPP                                                             */
  4. /*                                                                        */
  5. /*  Copyright Borland International 1991                                  */
  6. /*  All Rights Reserved                                                   */
  7. /*                                                                        */
  8. /*------------------------------------------------------------------------*/
  9.  
  10. #if !defined( __LTIME_H )
  11. #include <LTime.h>
  12. #endif  // __LTIME_H
  13.  
  14. #ifndef __IOMANIP_H
  15. #include <iomanip.h>
  16. #endif
  17.  
  18. #ifndef __STRSTREAM_H
  19. #include <strstream.h>
  20. #endif
  21.  
  22. #ifndef __STDIO_H
  23. #include <stdio.h>
  24. #endif
  25.  
  26. const BufSize = 20;
  27.  
  28. BaseTime::isEqual( const Object& testTime ) const
  29. {
  30.     return HH == ((BaseTime&)testTime).HH &&
  31.            MM == ((BaseTime&)testTime).MM &&
  32.            SS == ((BaseTime&)testTime).SS &&
  33.            HD == ((BaseTime&)testTime).HD;
  34. }
  35.  
  36. BaseTime::isLessThan( const Object& testTime ) const
  37. {
  38.     if( HH != ((BaseTime&)testTime).HH )
  39.         return HH < ((BaseTime&)testTime).HH;
  40.     if( MM != ((BaseTime&)testTime).MM )
  41.         return MM < ((BaseTime&)testTime).MM;
  42.     if( SS != ((BaseTime&)testTime).SS )
  43.         return SS < ((BaseTime&)testTime).SS;
  44.     if( HD != ((BaseTime&)testTime).HD )
  45.         return HD < ((BaseTime&)testTime).HD;
  46.     return 0;
  47. }
  48.  
  49. hashValueType BaseTime::hashValue() const
  50. {
  51.     return hashValueType( HH + MM + SS + HD );
  52. }
  53.  
  54. void Time::printOn( ostream& outputStream ) const
  55. {
  56.     char temp[BufSize];
  57.     ostrstream os( temp, BufSize );
  58.     os << ((hour()%12 == 0) ? 12 : hour()%12) << ":"
  59.        << setfill( '0' )
  60.        << setw( 2 ) << minute() << ":"
  61.        << setw( 2 ) << second() << "."
  62.        << setw( 2 ) << hundredths() << " "
  63.        << ((hour() > 11) ? "p" : "a") << "m" << ends;
  64.     outputStream << temp;
  65. }
  66.  
  67.