/////////////////////////////////////////////////////////// // Softwarebauelemente II, Aufgabe O3.1 // // author: Stephan Brumme // last changes: May 15, 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" #include using namespace std; /////////////////////////////////////////////////////////// // 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 hh:mm:ss class CDate : public CBasicClass { public: // constructor, default value is current date and time CDate(); // copy constructor CDate(const CDate &date); // set user defined date at construction time CDate(unsigned int nDay, unsigned int nMonth, unsigned int nYear, unsigned int nHour=0, unsigned int nMinute=0, unsigned int nSecond=0); // return class name virtual string ClassnameOf() const { return "CDate"; } // show attributes virtual string Show() const; // shows all internal attributes virtual string ShowDebug() const; // return today's date static void GetToday(unsigned int &nDay, unsigned int &nMonth, unsigned int &nYear, unsigned int &nHour, unsigned int &nMinute, unsigned int &nSecond); // validate a date virtual bool ClassInvariant() const; // determine whether it is a leap year static bool IsLeapYear(unsigned int nYear); // copy constructors // non virtual CDate& operator = (const CDate &date); // virtual virtual bool Copy (const CBasicClass *pClass); // compare two dates // non virtual bool operator == (const CDate &date) const; // virtual virtual bool EqualValue(const CBasicClass *pClass) const; // set attributes, returns validility of date void SetDay (unsigned int nDay); void SetMonth (unsigned int nMonth); void SetYear (unsigned int nYear); void SetHour (unsigned int nHour); void SetMinute(unsigned int nMinute); void SetSecond(unsigned int nSecond); // return attributes unsigned int GetDay () const; unsigned int GetMonth () const; unsigned int GetYear () const; unsigned int GetHour () const; unsigned int GetMinute() const; unsigned int GetSecond() const; // constants for month's 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 }; private: // attributes unsigned int m_nDay; unsigned int m_nMonth; unsigned int m_nYear; unsigned int m_nHour; unsigned int m_nMinute; unsigned int m_nSecond; }; #endif // !defined(AFX_DATE_H__A8EA7861_08E1_11D5_9BB7_A8652B9FDD20__INCLUDED_)