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