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 / LDATE.CPP < prev    next >
C/C++ Source or Header  |  1992-02-18  |  2KB  |  71 lines

  1. /*------------------------------------------------------------------------*/
  2. /*                                                                        */
  3. /*  LDATE.CPP                                                             */
  4. /*                                                                        */
  5. /*  Copyright Borland International 1991                                  */
  6. /*  All Rights Reserved                                                   */
  7. /*                                                                        */
  8. /*------------------------------------------------------------------------*/
  9.  
  10. #if !defined( __LDATE_H )
  11. #include <LDate.h>
  12. #endif  // __LDATE_H
  13.  
  14. #ifndef __STRSTREAM_H
  15. #include <strstream.h>
  16. #endif
  17.  
  18. #ifndef __STDIO_H
  19. #include <stdio.h>
  20. #endif
  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.