home *** CD-ROM | disk | FTP | other *** search
- #include "datecls.hpp"
-
- ////////////////////////////////////////////////////////////
- // main for testing purposes only...
- ////////////////////////////////////////////////////////////
-
- main()
- {
- // Various versions of the constructors
- // and various output
-
- Date x(10,20,1962);
- cout << x.formatDate(FULL) << "\n";
-
- // constuctor with a string, just printing the day of the week
- Date y="8/8/1988";
- cout << y.formatDate(DAY) << "\n";
-
- // constructor with a julian
- Date z( 2450000L );
- cout << z.formatDate(MDY) << '\n';
-
- // using date addition and subtraction
- Date a = x + 10;
- cout << a.formatDate(FULL) << '\n';
- a = a - 25;
- cout << a.formatDate(EUROPEAN) << '\n';
-
- //using subtraction of two date objects
- Date a1 = "7/13/1991";
- Date a2 = a1 + 14;
- cout << (a1-a2) << "\n";
- cout << (a2+=10) << "\n";
-
- a1++;
- cout << "Tommorrow= " << a1.formatDate(FULL) << "\n";
-
- cout << "a1 (7-14-91) < 8-01-91 ? ==> " << ((a1 < "08/01/1991") ? "TRUE" : "FALSE") << "\n";
- cout << "a1 (7-14-91) > 8-01-91 ? ==> " << ((a1 > "08/01/1991") ? "TRUE" : "FALSE") << "\n";
- cout << "a1 (7-14-91)== 7-14-91 ? ==> " << ((a1== "07/14/1991") ? "TRUE" : "FALSE") << "\n";
- Date a3 = a1;
- cout << "a1 (7-14-91)== a3 (7-14-91) ? ==> " << ((a1==a3) ? "TRUE" : "FALSE") << "\n";
- Date a4 = a1;
- cout << "a1 (7-14-91)== a4 (7-15-91) ? ==> " << ((a1==++a4) ? "TRUE" : "FALSE") << "\n";
-
- Date a5 = "today";
- cout << "Today is: " << a5 << "\n";
- a4 = "Today";
- cout << "Today (a4) is: " << a4 << "\n";
-
- cout << "Today + 4 is: " << (a4+=4) << "\n";
- a4 = "TODAY";
- cout << "Today - 4 is: " << (a4-=4) << "\n";
-
- cout << "=========== Leap Year Test ===========\n";
- a1 = "1/15/1992";
- cout << a1.formatDate(FULL) << "\t" << ((a1.isLeapYear()) ? "Leap" : "non-Leap");
- cout << "\t" << "day of year: " << a1.dayOfYear() << "\n";
-
- a1 = "2/16/1993";
- cout << a1.formatDate(FULL) << "\t" << ((a1.isLeapYear()) ? "Leap" : "non-Leap");
- cout << "\t" << "day of year: " << a1.dayOfYear() << "\n";
-
- date b0 = {1991,15,02};
- Date b1 = b0;
- cout << "=========== eom test ==============\n";
- cout << "b1.eom() (s/b 2/28/91) ==> " << b1.eom() << "\n";
-
- cout << "================== getDate test =====================\n";
- date ds = a1.getDate();
- cout << "a1.getDate() (s/b 2/16/1993) ==> " << ds << "\n";
-
- cout << "================== string assignment test ====================\n";
- char *date_string=a1;
- cout << "a1 as a string (s/b 2/16/1993) ==> " << date_string;
- }
-
-