/////////////////////////////////////////////////////////// // Softwarebauelemente II, Aufgabe O2.1 // // author: Stephan Brumme // last changes: February 26, 2001 #if !defined(AFX_DATE_H__A8EA7861_08E1_11D5_9BB7_A8652B9FDD20__INCLUDED_) #define AFX_DATE_H__A8EA7861_08E1_11D5_9BB7_A8652B9FDD20__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // for basic class behaviour #include "BasicClass.h" /////////////////////////////////////////////////////////// // the CDate class is based upon the Gregorian calender // it DOES work for year between ca. 1600 and <2^31 // no year validation is performed // // general order of parameters: dd/mm/yyyy class CDate : public CBasicClass { public: // constructor, default value is 0/0/00 (invalid date !) CDate(int nDay=0, int nMonth=0, int nYear=0); // show attributes friend ostream& operator<<(ostream &mystream, const CDate& date); // return class name static char* ClassnameOf() { return "CDate"; } // return current date static CDate GetToday(); // validate a date bool IsValid() const; // determine whether it is a leap year static bool IsLeapYear(int nYear); // copy constructors // non virtual CDate& operator = (const CDate &date); // virtual virtual bool Copy (const CDate *date); // compare two dates // non virtual bool operator ==(const CDate &date) const; // virtual virtual bool EqualValue(CDate *date) const; // set attributes, returns validility of date bool SetDay (int nDay); bool SetMonth(int nMonth); bool SetYear (int nYear); // return attributes int GetDay () const; int GetMonth() const; int GetYear () const; // constants for month names' enum { JANUARY = 1, FEBRUARY = 2, MARCH = 3, APRIL = 4, MAY = 5, JUNE = 6, JULY = 7, AUGUST = 8, SEPTEMBER = 9, OCTOBER =10, NOVEMBER =11, DECEMBER =12 }; protected: // used to perform proper display in derived classes virtual ostream& OutStream(ostream& mystream, bool bDebug=false) const; private: // attributes int m_nDay; int m_nMonth; int m_nYear; }; #endif // !defined(AFX_DATE_H__A8EA7861_08E1_11D5_9BB7_A8652B9FDD20__INCLUDED_)