home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / Dloads / OTHERUTI / TCPP10-8.ZIP / CLASSSRC.ZIP / LDATE.CPP < prev    next >
C/C++ Source or Header  |  1990-09-26  |  4KB  |  180 lines

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