#include "Date.h" Date::Date() { //constructor to assign todays date to date char data[9]; //holder for the date _strdate_s(data); //gets the current date mm/dd/yy string date=data; //copy to a string for parsing month=stoi(date.substr(0,2)); //gets characters 0 and 1 of date and converts to int day=stoi(date.substr(3,2)); //gets characters 3 and 4 of date and converts to int year=stoi(date.substr(6,2))+2000; //gets characters 6 and 7 of date and converts to int if(leapYear()) days2[2]=29; else days2[2]=28; for(int m=0;m<13;m++) days[m]=days2[m]; }//constructor for today static bool validDate(int m, int d, int y) { bool valid=true; //assume it is valid until found to be invalid if(y<1000) valid=false; if(m<1 || m>12) valid=false; if(leapYear(y)) days2[2]=29; else days2[2]=28; if(d<1 || d>days2[m]) valid=false; return valid; }//validDate Date::Date(int m, int d, int y) { //constructor to assign values to month day and year if(validDate(m,d,y)) { month=m; day=d; year=y; } else { month=day=1; year=1970; //Unix time starting point } //not valid: set to default valid date for(int m=0;m<13;m++) days[m]=days2[m]; } //constructor with assigned values Date::Date(int julian) { //Fliegel-Van Flandern algorithm to convert Julian date to Gregorian number month, day, and year gregorian(julian,month,day,year); if(leapYear()) days2[2]=29; else days2[2]=28; for(int m=0;m<13;m++) days[m]=days2[m]; }//Date Julian Date::Date (string str) { //constructor for todays date as "mm/dd/year //Parse str by adding one char at a s time to the token until a "/" is encounter. //When "/" is encountered start the next token //int p=0; int count=0; int num[3]; string token[3]; int len=str.length(); for(int p=0; p(const Date& otherDate) { //Convert both dates to Julian and compare the Julian dates int jd1=julian(); int jd2=otherDate.julian(); return jd1>jd2; }//operator ostream& operator << (ostream &output, const Date &d) { output << d.toString(); return output; } // operator << istream& operator >> (istream &input, Date &d) { string s; input >> s; Date other(s); //create a new Date d=other; //assign the new Date to d return input; } // operator >>