#include <afx.h>

#ifndef __MAGDATE_H__         
#define __MAGDATE_H__

#define DAYS_1900  693596
#define DAYS_1970  719163


class CMagicDate
{
public:

// Constructors
	static CMagicDate PASCAL GetCurrentDate();

	CMagicDate();
	CMagicDate(long date);
	CMagicDate(int nYear, int nMonth, int nDay);
	CMagicDate(const CTime& timeSrc);

	const CMagicDate& operator=(const CMagicDate& DateSrc);
	const CMagicDate& operator=(const CTime& t);
	const CMagicDate& operator=(long t);

// Attributes
	long GetMagicDate() const;
	int GetYear() const;
	int GetMonth() const;       // month of year (1 = Jan)
	int GetDay() const;         // day of month
    int GetDayOfWeek() const;   // day of week (1=Monday)                 
                       
// Operations
	// time math
	long operator-(CMagicDate time) const;
	CMagicDate operator-(long time) const;
	CMagicDate operator+(long time) const;
	const CMagicDate& operator+=(long time);
	const CMagicDate& operator-=(long time);
	int operator==(CMagicDate time) const;
	int operator!=(CMagicDate time) const;
	int operator<(CMagicDate time) const;
	int operator>(CMagicDate time) const;
	int operator<=(CMagicDate time) const;
	int operator>=(CMagicDate time) const;

	// formatting 
	CString Format(const char* pFormat) const;

private:
	long m_time;   
	long ToMagic(int Year,int Month,int Day) const;
};

#endif
