home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / bc45 / dates.pak / DATEX.CPP < prev    next >
C/C++ Source or Header  |  1997-07-23  |  1KB  |  41 lines

  1. // ---------------------------------------------------------------------------
  2. // Copyright (C) 1994 Borland International
  3. // date.cpp
  4. // ---------------------------------------------------------------------------
  5.  
  6. #include <classlib/date.h>
  7. #include <iostream.h>
  8.  
  9. void PrintDate(TDate& date)
  10. {
  11.     cout << date.NameOfDay() << " ";
  12.     cout << date.NameOfMonth() << " ";
  13.     cout << date.DayOfMonth() << ", " << date.Year();
  14. }
  15.  
  16. int main()
  17. {
  18.     TDate date;
  19.   
  20.     cout << "Welcome to TDate!" << endl << endl;
  21.     cout << "Please enter the date you were born (MM/DD/YY): ";
  22.     cin >> date;
  23.   
  24.     cout << "You were born on "; 
  25.     PrintDate(date);
  26.     cout << "." << endl;
  27.   
  28.     cout << "With 'operator <<', the date is " << date << endl << endl;
  29.   
  30.     cout << "The year " << date.Year() << " was";
  31.     cout << (date.Leap() ? "" : " not") << " a leap year." << endl;
  32.   
  33.     cout << "The week before that date was ";
  34.     PrintDate(date-7);
  35.     cout << "." << endl;
  36.   
  37.     cout << "The week after that date was " << (date+7) << endl;
  38.   
  39.     return 0;
  40. }
  41.