kdate - A Date Object (version 1.2) kdate is a C++ class that implements a date object. General: A kdate object holds a date in the range 1/1/1900 to 12/31/2099. Currently, kdate only implements a subset of a full-featured date object. In any sample code below, presume identifiers that start with: d are of type kdate s are of type kstring n are of type long kdate has four constructor functions: 1. A constructor with no arg; creates a 1/1/1900 date kdate d1; 2. A constructor with a c style string as an initial value kdate d2("6/10/95"); 3. A constructor with a kstring as an initial value kdate d3(s1); 4. A constructor with a month, day and year as an initial value kdate d4(m, d, y); The constructors with string arguments assume strings of the form "m/d/y" where m is the 1 or two digit month, d is the 1 or 2 digit day, and y is a 2 or four digit year. Two digit years are converted to four digit years as follows: if y, a two digit year is in the range first_two_digit_year to 99, add 1900 to y, else add 2000 to y. first_two_digit_year is set to 50. There is not a kdate destructor; no need for it; no dynamic memory. There are six member functions: long operator - (kdate & d); e.g. n_days = d3 - d2; // determine the number of days between dates kdate operator + (long delta_days); e.g. d1 = d2 + 100; // d2 is 100 days after d1 kdate operator - (long delta_days); e.g. d1 = d2 - 100; // d2 is 100 days before d1 kstring mm_dd_yy(); // converts kdate to a kstring in mm/dd/yy format e.g. cout << d2.mm_dd_yy() << endl; // displays 06/10/95 void get_m_d_y(int & month, int & day, int & year); e.g. d2.get(m, d, y); // sets m, d, and y to month, day & year in d2 int dow(); // day of week, 0 for sunday to 6 for saturday e.g. cout << d4.mm_dd_yy() << " is on " << day_name[d4.dow()] << endl; There is a global function: long daynum(int month, int day, int year); // returns days since 1/1/1900 There is one global variable (see text above about first_two_digit_year) int first_two_digit_year = 50; There is one global const: char * day_name[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};