home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c081_11 / 11.ddi / CLASSSRC.ZIP / LDATE.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-13  |  3.7 KB  |  172 lines

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