home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / CLOBSS.PAK / LDATE.CPO < prev    next >
Text File  |  1995-08-29  |  2KB  |  71 lines

  1. /*------------------------------------------------------------------------*/
  2. /*                                                                        */
  3. /*  LDATE.CPP                                                             */
  4. /*                                                                        */
  5. /*  Copyright Borland International 1991, 1993                            */
  6. /*  All Rights Reserved                                                   */
  7. /*                                                                        */
  8. /*------------------------------------------------------------------------*/
  9.  
  10. #if !defined( __STRSTREA_H )
  11. #include <strstrea.h>
  12. #endif    // __STRSTREA_H
  13.  
  14. #if !defined( __STDIO_H )
  15. #include <stdio.h>
  16. #endif    // __STDIO_H
  17.  
  18. #if !defined( __LDATE_H )
  19. #include "classlib\obsolete\ldate.h"
  20. #endif  // __LDATE_H
  21.  
  22. const BufSize = 20;
  23.  
  24. static char *MonthNames[] =
  25.     {
  26.     "",
  27.     "January",
  28.     "February",
  29.     "March",
  30.     "April",
  31.     "May",
  32.     "June",
  33.     "July",
  34.     "August",
  35.     "September",
  36.     "October",
  37.     "November",
  38.     "December"
  39.     };
  40.  
  41. int BaseDate::isEqual( const Object& testDate ) const
  42. {
  43.     return MM == ((BaseDate&)testDate).MM &&
  44.            DD == ((BaseDate&)testDate).DD &&
  45.            YY == ((BaseDate&)testDate).YY;
  46. }
  47.  
  48. int BaseDate::isLessThan( const Object& testDate ) const
  49. {
  50.     if( YY != ((BaseDate&)testDate).YY )
  51.         return YY < ((BaseDate&)testDate).YY;
  52.     if( MM != ((BaseDate&)testDate).MM )
  53.         return MM < ((BaseDate&)testDate).MM;
  54.     return DD < ((BaseDate&)testDate).DD;
  55. }
  56.  
  57. hashValueType BaseDate::hashValue() const
  58. {
  59.     return hashValueType( YY + MM + DD );
  60. }
  61.  
  62. void Date::printOn( ostream& outputStream ) const
  63. {
  64.     char temp[BufSize];
  65.     ostrstream os( temp, BufSize );
  66.     os << MonthNames[ Month() ] << " "
  67.        << Day() << ", " << Year() << ends;
  68.     outputStream << temp;
  69. }
  70.  
  71.