#pragma once #include #include #include #include using namespace std; class Date { private: int month, day, year; int days[13]; // number of days in each month void setDays(); // called when Date changes public: //constructors Date(); //constructor for todays date Date(int m, int d, int y); //constructor to assign date Date(string str); //constructor for todays date as "mm/dd/year Date(int julian); //constructor to convert a julian date to Date // Accessor methods int getMonth() const; //returns the private variable month int getDay() const; //returns the private variable day int getYear() const; //returns the private variable year // Methods to return other values string toString() const; //returns the string mm/dd/yyyy int dayofYear() const; //returns the day of the year: ie 2/1/???? is the 32 day of year int julian() const; int weekday() const; //returns 0 for Sunday, 1 for Monday, etc. //overloaded operators bool operator==(const Date& otherDate); //2 dates are equal if month, day and year are equal bool operator<(const Date& otherDate); //a date is < another date if it is earlier bool operator>(const Date& otherDate); //a date is > another date if it is later Date operator=(const Date& otherDate); //let's you copy one date to another. Date operator+(int); //Assign new values to the date after adding the number of days friend ostream& operator << (ostream &output, const Date &d); friend istream& operator >> (istream &input, Date &d); ~Date(); }; // Functions that are not part of class bool leapYear(int year); bool validDate(int m, int d, int y); //test other date void gregorian(int jd, int &mth, int &d, int &y); static int days2[] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };