#ifndef DATE_H
#define DATE_H
#include <iostream>
using namespace std;
const unsigned char daysInMonth[12] = {
31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};
static const char* dayNames[7] = {
"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"
};
static const char* monthNames[12] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
class Date {
private:
int d;
int m;
int y;
unsigned long j;
bool dayWithinMonth(int day, int month, int year) const;
unsigned long jday(int day, int month, int year) const;
void dmy();
static Date *td;
static Date& today(void);
public:
static bool printyear;
Date(int day = today().day(),
int month = today().month(),
int year = today().year());
~Date() {}
int day() const { return d; }
int month() const { return m; }
int year() const { return y; }
unsigned long julday() const { return j; }
const char* monthname() const { return monthNames[m-1]; }
int weekday() const { return j%7; }
const char* weekdayname() const { return dayNames[j%7]; }
int dayInYear() const { return j - jday(31, 12, y-1); }
Date previous(int desiredDayOfWeek) const;
long operator-(const Date& rhs) const { return j - rhs.j; }
const Date& operator+=(long days);
const Date operator+(long days);
const Date& operator-=(long days);
const Date operator-(long days);
};
ostream& operator<<(ostream& ostr, const Date& d);
bool leapYear(int year);
Date easter(int year);
#endif