home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c017 / 34.ddi / DATECLS3.ZIP / DATEDEMO.CPP < prev   
Encoding:
C/C++ Source or Header  |  1991-07-15  |  2.5 KB  |  78 lines

  1. #include "datecls.hpp"
  2.  
  3. ////////////////////////////////////////////////////////////
  4. //    main for testing purposes only...
  5. ////////////////////////////////////////////////////////////
  6.  
  7. main()
  8. {
  9.     // Various versions of the constructors
  10.     // and various output
  11.  
  12.     Date x(10,20,1962);
  13.     cout << x.formatDate(FULL) << "\n";
  14.  
  15.     // constuctor with a string, just printing the day of the week
  16.     Date y="8/8/1988";
  17.     cout << y.formatDate(DAY) << "\n";
  18.  
  19.     // constructor with a julian
  20.     Date z( 2450000L );
  21.     cout << z.formatDate(MDY) << '\n';
  22.  
  23.     // using date addition and subtraction
  24.     Date a = x + 10;
  25.     cout << a.formatDate(FULL) << '\n';
  26.     a = a - 25;
  27.     cout << a.formatDate(EUROPEAN) << '\n';
  28.  
  29.     //using subtraction of two date objects
  30.     Date a1 = "7/13/1991";
  31.     Date a2 = a1 + 14;
  32.     cout << (a1-a2) << "\n";
  33.     cout << (a2+=10) << "\n";
  34.  
  35.     a1++;
  36.     cout << "Tommorrow= " << a1.formatDate(FULL) << "\n";
  37.  
  38.     cout << "a1 (7-14-91) < 8-01-91 ? ==> " << ((a1 < "08/01/1991") ? "TRUE" : "FALSE") << "\n";
  39.     cout << "a1 (7-14-91) > 8-01-91 ? ==> " << ((a1 > "08/01/1991") ? "TRUE" : "FALSE") << "\n";
  40.     cout << "a1 (7-14-91)== 7-14-91 ? ==> " << ((a1== "07/14/1991") ? "TRUE" : "FALSE") << "\n";
  41.     Date a3 = a1;
  42.     cout << "a1 (7-14-91)== a3 (7-14-91) ? ==> " << ((a1==a3) ? "TRUE" : "FALSE") << "\n";
  43.     Date a4 = a1;
  44.     cout << "a1 (7-14-91)== a4 (7-15-91) ? ==> " << ((a1==++a4) ? "TRUE" : "FALSE") << "\n";
  45.  
  46.     Date a5 = "today";
  47.     cout << "Today is: " << a5 << "\n";
  48.     a4 = "Today";
  49.     cout << "Today (a4) is: " << a4 << "\n";
  50.  
  51.     cout << "Today + 4 is: " << (a4+=4) << "\n";
  52.     a4 = "TODAY";
  53.     cout << "Today - 4 is: " << (a4-=4) << "\n";
  54.  
  55.     cout << "=========== Leap Year Test ===========\n";
  56.     a1 = "1/15/1992";
  57.     cout << a1.formatDate(FULL) << "\t" << ((a1.isLeapYear()) ? "Leap" : "non-Leap");
  58.     cout << "\t" << "day of year:  " << a1.dayOfYear() << "\n";
  59.  
  60.     a1 = "2/16/1993";
  61.     cout << a1.formatDate(FULL) << "\t" << ((a1.isLeapYear()) ? "Leap" : "non-Leap");
  62.     cout << "\t" << "day of year:  " << a1.dayOfYear() << "\n";
  63.  
  64.     date b0 = {1991,15,02};
  65.     Date b1 = b0;
  66.     cout << "=========== eom test ==============\n";
  67.     cout << "b1.eom() (s/b 2/28/91) ==> " << b1.eom() << "\n";
  68.  
  69.     cout << "================== getDate test =====================\n";
  70.     date ds = a1.getDate();
  71.     cout << "a1.getDate()  (s/b 2/16/1993) ==> " << ds << "\n";
  72.  
  73.     cout << "================== string assignment test ====================\n";
  74.     char *date_string=a1;
  75.     cout << "a1 as a string (s/b 2/16/1993) ==> " << date_string;
  76. }
  77.  
  78.