home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / idate.inl < prev    next >
Encoding:
Text File  |  1996-02-22  |  4.1 KB  |  135 lines

  1. #ifndef _IDATE_INL_
  2. #define _IDATE_INL_ 0
  3. /*******************************************************************************
  4. * FILE NAME: idate.inl                                                         *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   This file contains the definition of the inline functions for the          *
  8. *   classes declared in idate.hpp.                                             *
  9. *                                                                              *
  10. * COPYRIGHT:                                                                   *
  11. *   IBM Open Class Library                                                     *
  12. *   (C) Copyright International Business Machines Corporation 1992, 1996       *
  13. *   Licensed Material - Program-Property of IBM - All Rights Reserved.         *
  14. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  15. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  16. *                                                                              *
  17. *******************************************************************************/
  18. #ifndef _IDATE_
  19.   #undef  _IDATE_INL_
  20.   #define _IDATE_INL_ 1
  21.   #include <idate.hpp>
  22. #endif
  23.  
  24. extern "C"
  25.   {
  26.   #include <time.h>
  27.   }
  28.  
  29. #if _IDATE_INL_
  30.   #define inline
  31. #endif
  32.  
  33. inline IDate IDate :: today ( )
  34.   {
  35.   time_t t   = time(0);
  36.   tm     now = *localtime( &t );
  37.   return IDate(  now.tm_year + 1900, now.tm_yday + 1 );
  38.   }
  39. inline IDate :: IDate ( )
  40.   {
  41.   this->julian = this->today().julian;
  42.   }
  43. inline IDate :: IDate ( int   aDay,
  44.                         Month aMonth,
  45.                         int   aYear )
  46.   {
  47.   this->initialize( aMonth, aDay, aYear );
  48.   }
  49. inline IDate :: IDate ( Month aMonth,
  50.                         int   aDay,
  51.                         int   aYear )
  52.   {
  53.   this->initialize( aMonth, aDay, aYear );
  54.   }
  55. inline IDate :: IDate ( const IDate& aDate )
  56.   : julian( aDate.julian )
  57.   {
  58.   }
  59. inline IDate :: IDate ( unsigned long julianDayNumber )
  60.   : julian( julianDayNumber )
  61.   {
  62.   }
  63.  
  64. inline IDate::DayOfWeek IDate :: dayOfWeek ( ) const
  65.   {
  66.   return (DayOfWeek) ( this->julian % 7 );
  67.   }
  68. inline unsigned long IDate :: julianDate ( ) const
  69.   {
  70.   return this->julian;
  71.   }
  72.  
  73. inline IBase::Boolean IDate :: operator == ( const IDate &aDate ) const
  74.   {
  75.   return this->julian == aDate.julian;
  76.   }
  77. inline IBase::Boolean IDate :: operator != ( const IDate &aDate ) const
  78.   {
  79.   return this->julian != aDate.julian;
  80.   }
  81. inline IBase::Boolean IDate :: operator <  ( const IDate &aDate ) const
  82.   {
  83.   return this->julian <  aDate.julian;
  84.   }
  85. inline IBase::Boolean IDate :: operator <= ( const IDate &aDate ) const
  86.   {
  87.   return this->julian <= aDate.julian;
  88.   }
  89. inline IBase::Boolean IDate :: operator >  ( const IDate &aDate ) const
  90.   {
  91.   return this->julian >  aDate.julian;
  92.   }
  93. inline IBase::Boolean IDate :: operator >= ( const IDate &aDate ) const
  94.   {
  95.   return this->julian >= aDate.julian;
  96.   }
  97.  
  98. inline IDate IDate :: operator + ( int numDays ) const
  99.   {
  100.   return IDate( this->julian + numDays );
  101.   }
  102. inline IDate IDate :: operator - ( int numDays ) const
  103.   {
  104.   return IDate( this->julian - numDays );
  105.   }
  106. inline IDate& IDate :: operator += ( int numDays )
  107.   {
  108.   this->julian += numDays;
  109.   return *this;
  110.   }
  111. inline IDate& IDate :: operator -= ( int numDays )
  112.   {
  113.   this->julian -= numDays;
  114.   return *this;
  115.   }
  116. inline long IDate :: operator - ( const IDate &aDate ) const
  117.   {
  118.   return this->julian - aDate.julian;
  119.   }
  120.  
  121. inline IBase::Boolean IDate :: isValid ( int   aDay,
  122.                                          Month aMonth,
  123.                                          int  aYear )
  124.   {
  125.   return IDate :: isValid( aMonth, aDay, aYear );
  126.   }
  127. inline IBase::Boolean IDate :: isValid ( int  aYear,
  128.                                          int  aDay )
  129.   {
  130.   return ( aYear != 0
  131.            &&
  132.            aDay <= IDate::daysInYear( aYear ) );
  133.   }
  134. #endif // _IDATE_INL_
  135.