sources:
C2_1.cpp (2.2k)
C2_1.h (1.4k)
C2_1Dlg.cpp (6.8k)
C2_1Dlg.h (1.7k)
Moment.cpp (5.7k)
Moment.h (2.7k)
PolymorphicSet.h (9.8k)
StdAfx.cpp (208 bytes)
StdAfx.h (1.1k)
resource.h (774 bytes)


binaries:
Release/C2_1.exe (28.0k)


website:
more info here
studies/bauelemente/Softwarebauelemente-CodeC2-1/Moment.h
download file

  1 ///////////////////////////////////////////////////////////
  2 // Softwarebauelemente II, C2.1
  3 //
  4 // author: Stephan Brumme
  5 // last changes: August 3, 2001
  6
  7 #if !defined(AFX_MOMENT_H__BA324DAD_872B_11D5_9BB8_AB7BB57BD00C__INCLUDED_)
  8 #define AFX_MOMENT_H__BA324DAD_872B_11D5_9BB8_AB7BB57BD00C__INCLUDED_
  9
 10 #if _MSC_VER > 1000
 11 #pragma once
 12 #endif // _MSC_VER > 1000
 13
 14 class CMoment : public CObject 
 15 {
 16     DECLARE_SERIAL(CMoment)
 17
 18 public:
 19     // constructor, default value is current date and time
 20     CMoment();
 21     // copy constructor
 22     CMoment(const CMoment& moment);
 23     // set user defined date at construction time
 24     CMoment(unsigned int nDay,    unsigned int nMonth,    unsigned int nYear,
 25             unsigned int nHour=0, unsigned int nMinute=0, unsigned int nSecond=0)
;
 26
 27     // destructor
 28     virtual ~CMoment();
 29
 30     // serialization
 31     void Serialize(CArchive &ar);
 32     // validate a moment
 33     virtual void AssertValid() const;
 34     // dump
 35     virtual void Dump(CDumpContext& dc) const;
 36
 37     // return current date and time
 38     static void GetCurrent(unsigned int& nDay,  unsigned int& nMonth,  unsigned int& nYear,
 39                            unsigned int& nHour, unsigned int& nMinute, unsigned int& nSecond)
;
 40
 41     // determine whether it is a leap year
 42     static bool IsLeapYear(unsigned int nYear);
 43
 44     // copy
 45     virtual CMoment& operator = (const CMoment& moment);
 46     virtual CMoment& Copy       (const CMoment& moment);
 47     // to enhance compatibility to CTime
 48     virtual CMoment& operator = (const CTime& time);
 49
 50     // compare two dates
 51     virtual bool     operator ==(const CMoment& moment) const;
 52     virtual bool     EqualValue (const CMoment& moment) const;
 53
 54     // convert to MFC's CTime
 55     virtual operator CTime() const;
 56
 57     // set attributes, returns validility of date
 58     void SetDay   (unsigned int nDay);
 59     void SetMonth (unsigned int nMonth);
 60     void SetYear  (unsigned int nYear);
 61     void SetHour  (unsigned int nHour);
 62     void SetMinute(unsigned int nMinute);
 63     void SetSecond(unsigned int nSecond);
 64
 65     // return attributes
 66     unsigned int GetDay   () const;
 67     unsigned int GetMonth () const;
 68     unsigned int GetYear  () const;
 69     unsigned int GetHour  () const;
 70     unsigned int GetMinute() const;
 71     unsigned int GetSecond() const;
 72
 73     // constants for month's names
 74     enum { JANUARY   =  1, FEBRUARY =  2, MARCH    =  3, APRIL    =  4,
 75            MAY       =  5, JUNE     =  6, JULY     =  7, AUGUST   =  8,
 76            SEPTEMBER =  9, OCTOBER  = 10, NOVEMBER = 11, DECEMBER = 12 };
 77
 78 private:
 79     // attributes
 80     unsigned int m_nDay;
 81     unsigned int m_nMonth;
 82     unsigned int m_nYear;
 83
 84     unsigned int m_nHour;
 85     unsigned int m_nMinute;
 86     unsigned int m_nSecond;
 87 };
 88
 89 #endif // !defined(AFX_MOMENT_H__BA324DAD_872B_11D5_9BB8_AB7BB57BD00C__INCLUDED_)
 90
 91