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 / LTIME.CPP < prev    next >
C/C++ Source or Header  |  1990-09-26  |  5KB  |  182 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. // Contents ----------------------------------------------------------------
  13. //
  14. //      BaseTime::operator String()
  15. //
  16. // Description
  17. //
  18. //      Implementation of class BaseTime member functions.
  19. //
  20. // End ---------------------------------------------------------------------
  21.  
  22. // Interface Dependencies ---------------------------------------------------
  23.  
  24. #ifndef __STRNG_H
  25. #include <strng.h>
  26. #endif
  27.  
  28. #ifndef __LTIME_H
  29. #include <ltime.h>
  30. #endif
  31.  
  32. // End Interface Dependencies ------------------------------------------------
  33.  
  34.  
  35. // Implementation Dependencies ----------------------------------------------
  36.  
  37. #ifndef __IOMANIP_H
  38. #include <iomanip.h>
  39. #endif
  40.  
  41. #ifndef __STRSTREAM_H
  42. #include <strstream.h>
  43. #endif
  44.  
  45. #ifndef __STDIO_H
  46. #include <stdio.h>
  47. #define __STDIO_H
  48. #endif
  49.  
  50. // End Implementation Dependencies -------------------------------------------
  51.  
  52.  
  53. const BufSize = 20;
  54.  
  55. // Member Function //
  56.  
  57. BaseTime::isEqual( const Object& testTime ) const
  58.  
  59. // Summary -----------------------------------------------------------------
  60. //
  61. //      Determines whether two times are equal.  Times are assumed to be
  62. //      normalized.
  63. //
  64. // Parameters
  65. //
  66. //      testTime
  67. //
  68. //      The time we are testing against this.
  69. //
  70. // End ---------------------------------------------------------------------
  71. {
  72.         return HH == ((BaseTime&)testTime).HH &&
  73.                MM == ((BaseTime&)testTime).MM &&
  74.                SS == ((BaseTime&)testTime).SS &&
  75.                HD == ((BaseTime&)testTime).HD;
  76. }
  77. // End Member Function Time::isEqual //
  78.  
  79. // Member Function //
  80.  
  81. BaseTime::isLessThan( const Object& testTime ) const
  82.  
  83. // Summary -----------------------------------------------------------------
  84. //
  85. //      Determines whether this time is less than the time passed as
  86. //        an argument.  Times are assumed to be normalized.
  87. //
  88. // Parameters
  89. //
  90. //      testTime
  91. //
  92. //      The time we are testing against this.
  93. //
  94. // End ---------------------------------------------------------------------
  95. {
  96.         if( HH != ((BaseTime&)testTime).HH )
  97.             return HH < ((BaseTime&)testTime).HH;
  98.         if( MM != ((BaseTime&)testTime).MM )
  99.             return MM < ((BaseTime&)testTime).MM;
  100.         if( SS != ((BaseTime&)testTime).SS )
  101.             return SS < ((BaseTime&)testTime).SS;
  102.         if( HD == ((BaseTime&)testTime).HD )
  103.             return HD < ((BaseTime&)testTime).HD;
  104. }
  105. // End Member Function Time::isEqual //
  106.  
  107. // Member Function //
  108.  
  109. hashValueType BaseTime::hashValue() const
  110.  
  111. // Summary -----------------------------------------------------------------
  112. //
  113. //      Returns the hash value of a string object.
  114. //
  115. // End ---------------------------------------------------------------------
  116. {
  117.     return hashValueType( HH + MM + SS + HD );
  118. }
  119. // End Member Function BaseTime::hashValue //
  120.  
  121.  
  122. // Member Function //
  123.  
  124. void Time::printOn( ostream& outputStream ) const
  125.  
  126. // Summary -----------------------------------------------------------------
  127. //
  128. //      Displays this object on the given stream.
  129. //
  130. // Parameters
  131. //
  132. //      outputStream
  133. //
  134. //      The stream where we are to display the object.
  135. //
  136. // End ---------------------------------------------------------------------
  137. {
  138.     char temp[16];
  139.  
  140.     ostrstream( temp, BufSize ) << 
  141.         ((hour()%12 == 0) ? 12 : hour()%12) << ":"
  142.         << setfill( '0' )
  143.         << setw( 2 ) << minute() << ":"
  144.         << setw( 2 ) << second() << "."
  145.         << setw( 2 ) << hundredths() << " "
  146.         << ((hour() > 11) ? "p" : "a") << "m" << ends;
  147.  
  148.     outputStream << temp;
  149. }
  150. // End Member Function Time::printOn //
  151.  
  152.  
  153. // Member Function //
  154.  
  155. classType Time::isA() const
  156.  
  157. // Summary -----------------------------------------------------------------
  158. //
  159. //      Returns the class type of a Time object.
  160. //
  161. // End ---------------------------------------------------------------------
  162. {
  163.     return timeClass;
  164. }
  165. // End Member Function Time::isA //
  166.  
  167.  
  168. // Member Function //
  169.  
  170. char *Time::nameOf() const
  171.  
  172. // Summary -----------------------------------------------------------------
  173. //
  174. //      Returns a pointer to the character string "Time."
  175. //
  176. // End ---------------------------------------------------------------------
  177. {
  178.     return "Time";
  179. }
  180. // End Member Function Time::nameOf //
  181.  
  182.