/////////////////////////////////////////////////////////// // Softwarebauelemente II, C2.1 // // author: Stephan Brumme // last changes: August 3, 2001 #if !defined(AFX_MOMENT_H__BA324DAD_872B_11D5_9BB8_AB7BB57BD00C__INCLUDED_) #define AFX_MOMENT_H__BA324DAD_872B_11D5_9BB8_AB7BB57BD00C__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 class CMoment : public CObject { DECLARE_SERIAL(CMoment) public: // constructor, default value is current date and time CMoment(); // copy constructor CMoment(const CMoment& moment); // set user defined date at construction time CMoment(unsigned int nDay, unsigned int nMonth, unsigned int nYear, unsigned int nHour=0, unsigned int nMinute=0, unsigned int nSecond=0); // destructor virtual ~CMoment(); // serialization void Serialize(CArchive &ar); // validate a moment virtual void AssertValid() const; // dump virtual void Dump(CDumpContext& dc) const; // return current date and time static void GetCurrent(unsigned int& nDay, unsigned int& nMonth, unsigned int& nYear, unsigned int& nHour, unsigned int& nMinute, unsigned int& nSecond); // determine whether it is a leap year static bool IsLeapYear(unsigned int nYear); // copy virtual CMoment& operator = (const CMoment& moment); virtual CMoment& Copy (const CMoment& moment); // to enhance compatibility to CTime virtual CMoment& operator = (const CTime& time); // compare two dates virtual bool operator ==(const CMoment& moment) const; virtual bool EqualValue (const CMoment& moment) const; // convert to MFC's CTime virtual operator CTime() 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_MOMENT_H__BA324DAD_872B_11D5_9BB8_AB7BB57BD00C__INCLUDED_)