home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0040 - 0049 / ibm0040-0049 / ibm0040.tar / ibm0040 / BCPPOWL1.ZIP / CLSRC.ZIP / LDATE.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-28  |  3.7 KB  |  171 lines

  1. // Borland C++ - (C) Copyright 1991 by Borland International
  2.  
  3. #ifndef __STRSTREAM_H
  4. #include <strstream.h>
  5. #endif
  6.  
  7. #ifndef __STDIO_H
  8. #include <stdio.h>
  9. #endif
  10.  
  11. #ifndef __STRNG_H
  12. #include <strng.h>
  13. #endif
  14.  
  15. #ifndef __LDATE_H
  16. #include <ldate.h>
  17. #endif
  18.  
  19.  
  20. const BufSize = 20;
  21.  
  22. static char *MonthNames[] =
  23.     {
  24.     "January",
  25.     "February",
  26.     "March",
  27.     "April",
  28.     "May",
  29.     "June",
  30.     "July",
  31.     "August",
  32.     "September",
  33.     "October",
  34.     "November",
  35.     "December"
  36.     };
  37.  
  38. // Member Function //
  39.  
  40. BaseDate::~BaseDate()
  41.  
  42. // Summary -----------------------------------------------------------------
  43. //
  44. //      Destructor for a BaseDate object.
  45. //
  46. // End ---------------------------------------------------------------------
  47. {
  48. }
  49. // End Destructor //
  50.  
  51.  
  52. // Member Function //
  53.  
  54. int BaseDate::isEqual( const Object& testDate ) const
  55.  
  56. // Summary -----------------------------------------------------------------
  57. //
  58. //      Determines whether two BaseDate objects are equal.
  59. //
  60. // End ---------------------------------------------------------------------
  61. {
  62.     return MM == ((BaseDate&)testDate).MM &&
  63.            DD == ((BaseDate&)testDate).DD &&
  64.            YY == ((BaseDate&)testDate).YY;
  65. }
  66. // End Function BaseDate::isEqual //
  67.  
  68.  
  69. // Member Function //
  70.  
  71. int BaseDate::isLessThan( const Object& testDate ) const
  72.  
  73. // Summary -----------------------------------------------------------------
  74. //
  75. //      Determines whether the current BaseDate is less than the BaseDate
  76. //      passed as an argument.
  77. //
  78. // End ---------------------------------------------------------------------
  79. {
  80.     if( YY != ((BaseDate&)testDate).YY )
  81.         return YY < ((BaseDate&)testDate).YY;
  82.     if( MM != ((BaseDate&)testDate).MM )
  83.         return MM < ((BaseDate&)testDate).MM;
  84.     return DD < ((BaseDate&)testDate).DD;
  85. }
  86. // End BaseDate::isLessThan //
  87.  
  88.  
  89. // Member Function //
  90.  
  91. hashValueType BaseDate::hashValue() const
  92.  
  93. // Summary -----------------------------------------------------------------
  94. //
  95. //      Returns the hash value of a string object.
  96. //
  97. // End ---------------------------------------------------------------------
  98. {
  99.     return hashValueType( YY + MM + DD );
  100. }
  101. // End Member Function BaseDate::hashValue //
  102.  
  103.  
  104. // Member Function //
  105.  
  106. Date::~Date()
  107.  
  108. // Summary -----------------------------------------------------------------
  109. //
  110. //      Destructor for a Date object.
  111. //
  112. // End ---------------------------------------------------------------------
  113. {
  114. }
  115. // End Destructor //
  116.  
  117.  
  118. // Member Function //
  119.  
  120. void Date::printOn( ostream& outputStream ) const
  121.  
  122. // Summary -----------------------------------------------------------------
  123. //
  124. //      Displays this object on the given stream.
  125. //
  126. // Parameters
  127. //
  128. //      outputStream
  129. //
  130. //      The stream where we are to display the object.
  131. //
  132. // End ---------------------------------------------------------------------
  133. {
  134.     char temp[BufSize];
  135.     ostrstream( temp, BufSize ) << MonthNames[ Month() ] << " " <<
  136.         Day() << "," << Year() << ends;
  137.     outputStream << temp;
  138. }
  139. // End Member Function Date::printOn //
  140.  
  141. // Member Function //
  142.  
  143. classType Date::isA() const
  144.  
  145. // Summary -----------------------------------------------------------------
  146. //
  147. //         Returns the class type of a Date.
  148. //
  149. // End ---------------------------------------------------------------------
  150. {
  151.     return dateClass;
  152. }
  153. // End Member Function Date::isA //
  154.  
  155.  
  156. // Member Function //
  157.  
  158. char *Date::nameOf() const
  159.  
  160. // Summary -----------------------------------------------------------------
  161. //
  162. //         Returns a pointer to the character string "Date."
  163. //
  164. // End ---------------------------------------------------------------------
  165. {
  166.     return "Date";
  167. }
  168. // End Member Function Date::nameOf //
  169.  
  170.  
  171.