home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / bc45 / clobss.pak / LTIME.CPO < prev    next >
Text File  |  1997-07-23  |  2KB  |  67 lines

  1. /*------------------------------------------------------------------------*/
  2. /*                                                                        */
  3. /*  LTIME.CPP                                                             */
  4. /*                                                                        */
  5. /*  Copyright Borland International 1991, 1993                            */
  6. /*  All Rights Reserved                                                   */
  7. /*                                                                        */
  8. /*------------------------------------------------------------------------*/
  9.  
  10. #if !defined( __IOMANIP_H )
  11. #include <iomanip.h>
  12. #endif    // __IOMANIP_H
  13.  
  14. #if !defined( __STRSTREA_H )
  15. #include <strstrea.h>
  16. #endif    // __STRSTREA_H
  17.  
  18. #if !defined( __STDIO_H )
  19. #include <stdio.h>
  20. #endif    // __STDIO_H
  21.  
  22. #if !defined( __LTIME_H )
  23. #include "classlib\obsolete\ltime.h"
  24. #endif  // __LTIME_H
  25.  
  26. const BufSize = 20;
  27.  
  28. int BaseTime::isEqual( const Object _FAR & 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. int 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.