home *** CD-ROM | disk | FTP | other *** search
/ CD World Haziran 1997 / CD World Haziran 1997.iso / Programlama ve Gelistirme / DTime / _SETUP.1 / Datetime.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-11-04  |  21.2 KB  |  690 lines

  1. /*
  2. Module : DATETIME.H
  3. Purpose: Defines the interface to a number of Date and Date/Time classes
  4. Created: PJN / DATE/1 / 05-05-1995
  5. History: None
  6.  
  7. Copyright (c) 1995 by PJ Naughter.  
  8. All rights reserved.
  9.  
  10. */
  11.  
  12. #ifndef __DATE_H__
  13.  
  14.  
  15. ////////////////////////////////// Macros /////////////////////////////////////
  16.  
  17. #define __DATE_H__
  18.  
  19.                       
  20.  
  21. ////////////////////////////////// Includes ///////////////////////////////////
  22.  
  23. #include <afx.h>
  24. #include <iostream.h>
  25.  
  26.  
  27.  
  28. ////////////////////////////// Date Enums & Structs ///////////////////////////
  29.  
  30. //flags used to control how the CLTimeSpan::Format(DWORD dwFlags), 
  31. //CLTimeOfDay::Format(DWORD dwFlags) and CLDate::Format(DWORD dwFlags) behave
  32. const DWORD DTF_NOSECOND         = 0x0001;   //do not include the second field
  33. const DWORD DTF_NOTIMEFRAME      = 0x0002;   //Do not include the TimeFrame field
  34.  
  35. enum CalendarType { JULIAN, GREGORIAN };
  36.  
  37.  
  38. struct DateS
  39. {
  40.   LONG lYear;
  41.   WORD wMonth;
  42.   WORD wDay;
  43.   WORD wWday;
  44.   WORD wYday;
  45.   CalendarType ct;
  46. };
  47.  
  48.  
  49. enum TimeFrame {UCT=0,
  50.                 ET, 
  51.                 LOCAL};
  52.  
  53.  
  54. struct DateLS
  55. {
  56.   LONG lYear;
  57.   WORD wMonth;
  58.   WORD wDay;
  59.   WORD wWday;
  60.   WORD wYday;
  61.   WORD wHour;
  62.   WORD wMinute;
  63.   WORD wSecond;
  64.   CalendarType ct;
  65.   TimeFrame tf;
  66. };
  67.  
  68.  
  69. /////////////////////////////// Free sub-programs (aka functions) /////////////
  70.    
  71. //Archive operators for 64 bit integers
  72.                                             
  73. //This need to be provided as currently MFC does not support archiving of
  74. //64 bit integers. When this become part of MFC, the will be removed
  75. //from here
  76. inline CArchive& AFX_EXT_API operator<<(CArchive& ar, __int64 nInt64)
  77.   ar.Write(&nInt64, sizeof(__int64)); 
  78.   return ar; 
  79. };
  80.  
  81. inline CArchive& AFX_EXT_API operator>>(CArchive& ar, __int64 nInt64)
  82.   ar.Read(&nInt64, sizeof(__int64)); 
  83.   return ar; 
  84. };
  85.  
  86. inline CArchive& AFX_EXT_API operator<<(CArchive& ar, unsigned __int64 nInt64)
  87.   ar.Write(&nInt64, sizeof(unsigned __int64)); 
  88.   return ar; 
  89. };
  90.  
  91. inline CArchive& AFX_EXT_API operator>>(CArchive& ar, unsigned __int64 nInt64)
  92.   ar.Read(&nInt64, sizeof(unsigned __int64)); 
  93.   return ar; 
  94. };
  95.  
  96.  
  97. void AFX_EXT_API InitDTime();    //Should be called when initialising DTime and in
  98.                                  //response to WM_SETTINGCHANGE messages
  99.  
  100.  
  101.      
  102.  
  103. /////////////////////////////// Classes ///////////////////////////////////////
  104.  
  105. // forward declarations
  106. class CLDate;
  107. class CLTimeOfDay;
  108.    
  109.    
  110.    
  111.    
  112. // A Date class with a granularity of 1 Day
  113.  
  114. class AFX_EXT_CLASS CDate : public CObject
  115. {
  116.   DECLARE_SERIAL(CDate)
  117.  
  118. public:
  119.   friend class CLDate;
  120.  
  121.   enum MONTH { JANUARY=1,
  122.                FEBRUARY,
  123.                MARCH,
  124.                APRIL,
  125.                MAY,
  126.                JUNE,
  127.                JULY,
  128.                AUGUST,
  129.                SEPTEMBER,
  130.                OCTOBER,
  131.                NOVEMBER,
  132.                DECEMBER};
  133.  
  134.   enum DayOfWeek { SUNDAY=1,
  135.                    MONDAY,
  136.                    TUESDAY,
  137.                    WEDNESDAY,
  138.                    THURSDAY,
  139.                    FRIDAY,
  140.                    SATURDAY};
  141.  
  142.   enum DateEpoch { EPOCH_JD,
  143.                    EPOCH_MJD,
  144.                    EPOCH_1900,
  145.                    EPOCH_1950,
  146.                    EPOCH_CTIME,
  147.                    EPOCH_2000,
  148.                    EPOCH_GREG};
  149.   
  150.  
  151.   //constructors
  152.   CDate();
  153.   CDate(LONG Year, WORD Month, WORD Day);
  154.   CDate(const SYSTEMTIME& st);
  155.   CDate(LONG Year, WORD Month, WORD WeekOfMonth, WORD DayOfWeek); 
  156.   CDate(LONG Days, DateEpoch e);
  157.   CDate(const CDate& d);
  158.   CDate(const CTime& ctime);
  159.   CDate(const COleDateTime& oleTime);
  160.  
  161.  
  162.   //Set operators
  163.   CDate& Set();
  164.   CDate& Set(LONG Year, WORD Month, WORD Day);
  165.   CDate& Set(const SYSTEMTIME& st);
  166.   CDate& Set(LONG Year, WORD Month, WORD WeekOfMonth, WORD DayOfWeek); 
  167.   CDate& Set(LONG Days, DateEpoch e);
  168.   CDate& Set(const CTime& ctime);
  169.   CDate& Set(const COleDateTime& oleTime);
  170.  
  171.  
  172.   //statics constructors
  173.   static CDate CurrentDate();
  174.   static CDate FirstCurrentMonth(); 
  175.   static CDate LastCurrentMonth();  
  176.   static CDate FirstCurrentYear();
  177.   static CDate LastCurrentYear();
  178.   static CDate JDEpoch(); 
  179.   static CDate MJDEpoch();
  180.   static CDate Epoch1900();
  181.   static CDate Epoch1950();
  182.   static CDate EpochCTime();
  183.   static CDate Epoch2000();
  184.   static CDate GregorianEpoch();
  185.  
  186.  
  187.   //static operations
  188.   static BOOL    InitCalendarSettings();
  189.   static void    GetDefaultFormat();
  190.   static BOOL    IsLeap(LONG Year);
  191.   static WORD    DaysInYear(LONG Year);
  192.   static WORD    DaysInMonth(WORD Month, BOOL IsLeap);
  193.   static WORD    DaysSinceJan1(WORD Month, WORD Day, BOOL IsLeap);
  194.   static WORD    DaysSinceJan0(WORD Month, WORD Day, BOOL IsLeap);
  195.   static WORD    CurrentMonth();
  196.   static WORD    CurrentDay();
  197.   static LONG    CurrentYear();
  198.   static WORD    CurrentDayOfWeek();
  199.   static WORD    GetBeginingDayOfWeek();
  200.   static BOOL    SetEndJulianCalendar(LONG Year, WORD Month, WORD Day);
  201.   static BOOL    SetBeginGregorianCalendar(LONG Year, WORD Month, WORD Day);
  202.   static void    GetEndJulianCalendar(LONG& Year, WORD& Month, WORD& Day);
  203.   static void    GetBeginGregorianCalendar(LONG& Year, WORD& Month, WORD& Day);
  204.   static BOOL    InGregorianCalendar(LONG Year, WORD Month, WORD Day);
  205.   static BOOL    InJulianCalendar(LONG Year, WORD Month, WORD Day);
  206. #ifdef _DEBUG
  207.   static BOOL    SetDoConstructorAsserts(BOOL bDoAsserts);
  208. #endif
  209.   static CString GetFullStringDayOfWeek(WORD DayOfWeek);
  210.   static CString GetAbrStringDayOfWeek(WORD DayOfWeek);
  211.   static CString GetFullStringMonth(WORD Month);
  212.   static CString GetAbrStringMonth(WORD Month);
  213.   static LONG    EndJulianYear();
  214.   static WORD    EndJulianMonth();
  215.   static WORD    EndJulianDay();
  216.   static LONG    BeginGregorianYear();
  217.   static WORD    BeginGregorianMonth();
  218.   static WORD    BeginGregorianDay();
  219.   
  220.  
  221.   
  222.   //static Holiday constructors
  223.   static CDate NewYearsDay(LONG Year=CDate::CurrentYear());
  224.   static CDate ValentinesDay(LONG Year=CDate::CurrentYear());
  225.   static CDate AshWednesday(LONG Year=CDate::CurrentYear());
  226.   static CDate StPatricksDay(LONG Year=CDate::CurrentYear());
  227.   static CDate GoodFriday(LONG Year=CDate::CurrentYear());
  228.   static CDate EasterSunday(LONG Year=CDate::CurrentYear());
  229.   static CDate CanadaDay(LONG Year=CDate::CurrentYear());
  230.   static CDate IndependenceDay(LONG Year=CDate::CurrentYear());
  231.   static CDate BastilleDay(LONG Year=CDate::CurrentYear());
  232.   static CDate ChristmasDay(LONG Year=CDate::CurrentYear());
  233.  
  234.   
  235.   //Operations
  236.   WORD       DaysSinceJan1() const;
  237.   WORD       DaysSinceJan0() const;
  238.   DateS      GetDate() const;
  239.   WORD       GetDay() const;
  240.   WORD       GetMonth() const;
  241.   LONG       GetYear() const;
  242.   LONG       GetCEBCEYear(BOOL& IsCE) const;
  243.   WORD       Get2DigitYear() const;
  244.   LONG       Since1900Epoch() const;
  245.   LONG       Since1950Epoch() const;
  246.   LONG       SinceCTimeEpoch() const;
  247.   LONG       Since2000Epoch() const;
  248.   LONG       GDN() const;
  249.   LONG       GetValue() const;
  250.   LONG       JD() const;
  251.   BOOL       IsLeap() const;
  252.   WORD       DaysInYear() const;
  253.   WORD       DaysInMonth() const;
  254.   void       AddYear(int Years=1);
  255.   void       AddWeek(int Weeks=1);
  256.   void       AddMonth(int Months=1);
  257.   WORD       GetDayOfWeek() const; 
  258.   CString    GetStringCEBCEYear() const;    
  259.   CString    GetFullStringDayOfWeek() const;
  260.   CString    GetAbrStringDayOfWeek() const;
  261.   CString    GetFullStringMonth() const;
  262.   CString    GetAbrStringMonth() const;
  263.   SYSTEMTIME GetSYSTEMTIME() const;
  264.   tm         GetTM() const;
  265.   WORD       GetWeekOfYear() const;    
  266.   WORD       GetWeekOfMonth() const;
  267.   BOOL       IsValid() const;          
  268.   LONG       Collate() const;          
  269.   BOOL       InGregorianCalendar() const;
  270.   BOOL       InJulianCalendar() const;
  271.                                           
  272.                                         
  273.   //Creation of other CDate's from this instance
  274.   CDate FirstThisMonth() const;
  275.   CDate LastThisMonth() const;
  276.   CDate FirstThisYear() const;
  277.   CDate LastThisYear() const;
  278.   
  279.  
  280.   //Overloaded Arithmetic Operators
  281.   CDate& operator=(const CDate& d);
  282.   CDate  operator+(LONG Days) const;
  283.   LONG   operator-(const CDate& d) const;
  284.   CDate  operator-(LONG Days) const;
  285.   CDate& operator+=(LONG Days);
  286.   CDate& operator-=(LONG Days);
  287.   CDate& operator++();
  288.   CDate& operator--();
  289.  
  290.  
  291.   //Overloaded Equality operators
  292.   BOOL operator==(const CDate& d) const;
  293.   BOOL operator>(const CDate& d) const;
  294.   BOOL operator>=(const CDate& d) const;
  295.   BOOL operator<(const CDate& d) const;
  296.   BOOL operator<=(const CDate& d) const;
  297.   BOOL operator!=(const CDate& d) const;
  298.  
  299.  
  300.   //Diagnostics / Debug
  301.   #ifdef _DEBUG
  302.   virtual void AssertValid() const;
  303.   virtual void Dump(CDumpContext& dc) const;
  304.   #endif
  305.  
  306.  
  307.   //Display
  308.   CString Format(const CString& sFormat) const;  //Format using a format specifier string
  309.   CString Format() const;                        //Format using the current NLSAPI settings
  310.   
  311.  
  312.   //Serialization
  313.   virtual void Serialize(CArchive& ar);
  314.  
  315.  
  316.   //streaming
  317.   friend AFX_EXT_API ostream&   operator<<(ostream& os, const CDate& Date);
  318.   friend AFX_EXT_API CArchive&  operator<<(CArchive& ar, CDate& Date);
  319.   friend AFX_EXT_API CArchive&  operator>>(CArchive& ar, CDate& Date);
  320.   
  321.  
  322. protected:
  323.   LONG m_lDays;                      //Count of days since 15 October 1582 (Gregorian Calendrical System or n.s) 
  324.   BOOL m_bInGregCalendar;            //Is this date in the Gregorian Calendar
  325.   BOOL m_bValid;                     //Is this a valid instance
  326.  
  327.   static BOOL sm_bDoAsserts;         //Do constructor asserts
  328.  
  329.  
  330.   //Following values are managed by CDate::InitCalendarSettings and CDate::GetDefaultFormat
  331.   static LONG    sm_lEndJulianYear;     //The Date when the Julian Calendar Finished
  332.   static WORD    sm_wEndJulianMonth;
  333.   static WORD    sm_wEndJulianDay;
  334.   static LONG    sm_lBeginGregYear;     //The Date when the Gregorian Calendar Started
  335.   static WORD    sm_wBeginGregMonth;
  336.   static WORD    sm_wBeginGregDay;
  337.   static CString sm_sDefaultFormat;     //Format string to use in Format()
  338. };
  339.  
  340.  
  341.  
  342.  
  343. // A Time span class with a granularity of 1 second which
  344. // is used in conjunction with the time class CLDate
  345.  
  346. class AFX_EXT_CLASS CLTimeSpan : public CObject
  347. {
  348. public:
  349.   friend class CLDate;
  350.   friend class CLTimeOfDay;
  351.  
  352.   DECLARE_SERIAL(CLTimeSpan)
  353.     
  354.   //constructors
  355.   CLTimeSpan();
  356.   CLTimeSpan(LONG Day, WORD Hour, WORD Minute, WORD Second);
  357.   CLTimeSpan(const CLTimeSpan& lts);
  358.   CLTimeSpan(const CTimeSpan& ts);
  359.   CLTimeSpan(const CLTimeOfDay& tod);
  360.   CLTimeSpan(const COleDateTimeSpan& oleTimeSpan);
  361.   CLTimeSpan(const __int64& Seconds);
  362.  
  363.  
  364.   //Set operators
  365.   CLTimeSpan& Set();
  366.   CLTimeSpan& Set(LONG Day, WORD Hour, WORD Minute, WORD Second);
  367.   CLTimeSpan& Set(const CTimeSpan& ts);
  368.   CLTimeSpan& Set(const CLTimeOfDay& tod);
  369.   CLTimeSpan& Set(const COleDateTimeSpan& oleTimeSpan);
  370.   CLTimeSpan& Set(const __int64& Seconds);
  371.  
  372.   
  373.   //statics constructors
  374.   static CLTimeSpan OneCivilYear();
  375.   static CLTimeSpan OneDay();
  376.   static CLTimeSpan OneHour();
  377.   static CLTimeSpan OneMinute();
  378.   static CLTimeSpan OneSecond();
  379.   
  380.   //static operations
  381.   static void GetDefaultFormat();
  382. #ifdef _DEBUG
  383.   static BOOL SetDoConstructorAsserts(BOOL bDoAsserts);
  384. #endif                                                            
  385.  
  386.   
  387.   //Operations
  388.   LONG        GetTotalDays() const; 
  389.   WORD        GetHours() const; 
  390.   WORD        GetMinutes() const; 
  391.   WORD        GetSeconds() const; 
  392.   BOOL        IsValid() const; 
  393.   CLTimeSpan& Negate();
  394.   BOOL        IsPositiveSpan() const;
  395.   double      SecondsAsDouble() const;
  396.                                            
  397.                                         
  398.   //Overloaded Arithmetic Operators
  399.   CLTimeSpan&                   operator=(const CLTimeSpan& TimeSpan);
  400.   CLTimeSpan                    operator+(const CLTimeSpan& TimeSpan) const;
  401.   CLTimeSpan                    operator-(const CLTimeSpan& TimeSpan) const;
  402.   CLTimeSpan&                   operator+=(CLTimeSpan& TimeSpan);
  403.   CLTimeSpan&                   operator-=(CLTimeSpan& TimeSpan);
  404.   friend AFX_EXT_API CLTimeSpan operator-(const CLTimeSpan& TimeSpan);
  405.   CLTimeSpan                    operator*(WORD Multiplier) const;
  406.   friend AFX_EXT_API CLTimeSpan operator*(WORD Multiplier, const CLTimeSpan& TimeSpan);
  407.   CLTimeSpan                    operator/(WORD divisor) const;
  408.   CLTimeSpan&                   operator*=(WORD Multiplier);
  409.   CLTimeSpan&                   operator/=(WORD Divisor);
  410.   
  411.  
  412.  
  413.   //Overloaded Equality operators
  414.   BOOL operator==(const CLTimeSpan& TimeSpan) const;
  415.   BOOL operator>(const CLTimeSpan& TimeSpan) const;
  416.   BOOL operator>=(const CLTimeSpan& TimeSpan) const;
  417.   BOOL operator<(const CLTimeSpan& TimeSpan) const;
  418.   BOOL operator<=(const CLTimeSpan& TimeSpan) const;
  419.   BOOL operator!=(const CLTimeSpan& TimeSpan) const;
  420.  
  421.  
  422.   //Diagnostics / Debug
  423.   #ifdef _DEBUG
  424.   virtual void AssertValid() const;
  425.   virtual void Dump(CDumpContext& dc) const;
  426.   #endif
  427.  
  428.  
  429.   //Display
  430.   CString Format(const CString& sFormat) const;  //Format using a format specifier string
  431.   CString Format(DWORD dwFlags = 0) const;       //Format using the current NLSAPI settings
  432.   
  433.  
  434.   //Serialization
  435.   virtual void Serialize(CArchive& ar);
  436.  
  437.  
  438.   //streaming
  439.   friend AFX_EXT_API ostream&  operator<<(ostream& os, const CLTimeSpan& TimeSpan);
  440.   friend AFX_EXT_API CArchive& operator<<(CArchive& ar, CLTimeSpan& TimeSpan);
  441.   friend AFX_EXT_API CArchive& operator>>(CArchive& ar, CLTimeSpan& TimeSpan);
  442.   
  443.          
  444. protected:
  445.   __int64 m_nSeconds;                   //Actual instance data
  446.   BOOL    m_bValid;                     //Is this a valid instance
  447.  
  448.   static BOOL sm_bDoAsserts;            //Do Constructor asserts
  449.   static CString sm_sDefaultFormat;     //Format string to use in Format()
  450.   static CString sm_sDefaultFormatNOS;  //Format string to use in Format() with DTF_NOSECOND
  451. };
  452.  
  453.  
  454.  
  455.  
  456. // A Time of Day class with a granularity of 1 second which
  457. // is used in conjunction with the time class CDate in the CLDate class
  458.  
  459. class AFX_EXT_CLASS CLTimeOfDay : public CObject
  460. {
  461. public:
  462.   friend class CLDate;
  463.   
  464.   DECLARE_SERIAL(CLTimeOfDay)
  465.  
  466.   //constructors
  467.   CLTimeOfDay();
  468.   CLTimeOfDay(WORD Hour, WORD Minute, WORD Second);
  469.   CLTimeOfDay(const SYSTEMTIME& st);             
  470.   CLTimeOfDay(const CLTimeOfDay& ltod);
  471.   CLTimeOfDay(DWORD TotalSeconds);
  472.  
  473.  
  474.   //Set operators
  475.   CLTimeOfDay& Set();
  476.   CLTimeOfDay& Set(WORD Hour, WORD Minute, WORD Second);
  477.   CLTimeOfDay& Set(const SYSTEMTIME& st);          
  478.   CLTimeOfDay& Set(DWORD TotalSeconds);   
  479.  
  480.  
  481.   //statics constructors              
  482.   static CLTimeOfDay CurrentTimeOfDay(TimeFrame tf);
  483.   static CLTimeOfDay Midnight();
  484.   static CLTimeOfDay Midday();
  485.  
  486.   
  487.   //static operations
  488.   static void GetDefaultFormat();
  489. #ifdef _DEBUG
  490.   static BOOL    SetDoConstructorAsserts(BOOL bDoAsserts);
  491. #endif
  492.   static CString GetAMString();
  493.   static CString GetPMString();
  494.  
  495.   
  496.   //Operations
  497.   WORD           GetHour() const; 
  498.   WORD           GetMinute() const; 
  499.   WORD           GetSecond() const; 
  500.   DWORD          GetTotalSeconds() const;
  501.   WORD           GetAMPMHour() const; 
  502.   CString        GetAMPMString() const;
  503.   BOOL           IsValid() const;          
  504.   DWORD          Collate() const;
  505.   SYSTEMTIME     GetSYSTEMTIME() const;
  506.   tm             GetTM() const;
  507.                                       
  508.                                         
  509.   //Overloaded Arithmetic Operators
  510.   CLTimeOfDay& operator=(const CLTimeOfDay& Tod);
  511.   CLTimeOfDay  operator+(const CLTimeSpan& TimeSpan) const;
  512.   CLTimeOfDay  operator-(const CLTimeSpan& TimeSpan) const;
  513.   CLTimeOfDay& operator+=(CLTimeSpan& TimeSpan);
  514.   CLTimeOfDay& operator-=(CLTimeSpan& TimeSpan);
  515.  
  516.  
  517.   //Overloaded Equality operators
  518.   BOOL operator==(const CLTimeOfDay& Tod) const;
  519.   BOOL operator>(const CLTimeOfDay& Tod) const;
  520.   BOOL operator>=(const CLTimeOfDay& Tod) const;
  521.   BOOL operator<(const CLTimeOfDay& Tod) const;
  522.   BOOL operator<=(const CLTimeOfDay& Tod) const;
  523.   BOOL operator!=(const CLTimeOfDay& Tod) const;
  524.  
  525.  
  526.   //Diagnostics / Debug
  527.   #ifdef _DEBUG
  528.   virtual void AssertValid() const;
  529.   virtual void Dump(CDumpContext& dc) const;
  530.   #endif
  531.  
  532.  
  533.   //Display
  534.   CString Format(const CString& sFormat) const;  //Format using a format specifier string
  535.   CString Format(DWORD dwFlags = 0) const;       //Format using the current NLSAPI settings
  536.  
  537.  
  538.   //Serialization
  539.   virtual void Serialize(CArchive& ar);
  540.  
  541.  
  542.   //streaming
  543.   friend AFX_EXT_API ostream&  operator<<(ostream& os, const CLTimeOfDay& Tod);
  544.   friend AFX_EXT_API CArchive& operator<<(CArchive& ar, CLTimeOfDay& Tod);
  545.   friend AFX_EXT_API CArchive& operator>>(CArchive& ar, CLTimeOfDay& Tod);
  546.   
  547.          
  548. protected:
  549.   DWORD m_dwTotalSeconds;               //Actual instance data 
  550.   BOOL  m_bValid;                       //Is this a valid instance
  551.  
  552.   static BOOL sm_bDoAsserts;            //Do Constructor asserts
  553.   static CString sm_sDefaultFormat;     //Format string to use in Format()
  554.   static CString sm_sDefaultFormatNOS;  //Format string to use in Format()  with DTF_NOSECOND
  555. };
  556.  
  557.  
  558.  
  559.  
  560. // A Date class with a granularity of 1 second
  561.  
  562. class AFX_EXT_CLASS CLDate : public CObject
  563. {
  564. public:
  565.   DECLARE_SERIAL(CLDate)
  566.    
  567.   //constructors
  568.   CLDate();
  569.   CLDate(LONG Year, WORD Month, WORD Day, WORD Hour, WORD Minute, WORD Second, TimeFrame tf);
  570.   CLDate(const SYSTEMTIME& st, TimeFrame tf, BOOL bUseDayOfWeek=FALSE);
  571.   CLDate(LONG Year, WORD Month, WORD WeekOfMonth, WORD DayOfWeek, WORD Hour, WORD Minute, WORD Second, TimeFrame tf); 
  572.   CLDate(LONG Days, CDate::DateEpoch e, WORD Hour, WORD Minute, WORD Second, TimeFrame tf);
  573.   CLDate(const CLDate& ld);
  574.   CLDate(const CTime& ct);
  575.   CLDate(const CDate& Date, const CLTimeOfDay& Tod, TimeFrame tf);
  576.   CLDate(const COleDateTime& oleTime, TimeFrame tf);
  577.  
  578.  
  579.   //Set operators
  580.   CLDate& Set();
  581.   CLDate& Set(LONG Year, WORD Month, WORD Day, WORD Hour, WORD Minute, WORD Second, TimeFrame tf);
  582.   CLDate& Set(const SYSTEMTIME& st, TimeFrame tf, BOOL bUseDayOfWeek=FALSE);           
  583.   CLDate& Set(LONG Year, WORD Month, WORD WeekOfMonth, WORD DayOfWeek, WORD Hour, WORD Minute, WORD Second, TimeFrame tf); 
  584.   CLDate& Set(LONG Days, CDate::DateEpoch e, WORD Hour, WORD Minute, WORD Second, TimeFrame tf);
  585.   CLDate& Set(const CTime& ct);         
  586.   CLDate& Set(const CDate& Date, const CLTimeOfDay& Tod, TimeFrame tf);
  587.   CLDate& Set(const COleDateTime& oleTime, TimeFrame tf);
  588.  
  589.  
  590.   //static constructors
  591.   static CLDate CurrentTime(TimeFrame tf);
  592.  
  593.   
  594.   //static operations
  595.   static CLTimeSpan DeltaT(CLDate& ld);
  596.   static BOOL       CurrentlyInDST();
  597.   static CLTimeSpan DaylightBias();
  598.   static CLTimeSpan TimezoneBias();
  599.   static CString    DaylightName();
  600.   static CString    StandardName();
  601. #ifdef _DEBUG
  602.   static BOOL SetDoConstructorAsserts(BOOL bDoAsserts);
  603. #endif
  604.   
  605.  
  606.   //Operations
  607.   CDate       GetCDate() const;
  608.   CLTimeOfDay GetCLTimeOfDay() const;
  609.   DateLS      GetDate() const;
  610.   SYSTEMTIME  GetSYSTEMTIME() const;
  611.   tm          GetTM();  
  612.   void        AddYear(int Years=1);
  613.   void        AddWeek(int Weeks=1);
  614.   void        AddMonth(int Months=1);
  615.   BOOL        IsValid() const;
  616.   CLTimeSpan  DeltaT();
  617.   TimeFrame   SetTimeFrame(TimeFrame tf);
  618.   TimeFrame   GetTimeFrame() const;
  619.   BOOL        IsDST();
  620.   CString     GetStringTimeFrame() const;
  621.                                      
  622.                                         
  623.   //Overloaded Arithmetic Operators
  624.   CLDate&    operator=(const CLDate& ld);
  625.   CLDate     operator+(const CLTimeSpan& TimeSpan);
  626.   CLTimeSpan operator-(CLDate& ld);
  627.   CLDate     operator-(const CLTimeSpan& TimeSpan);
  628.   CLDate&    operator+=(const CLTimeSpan& TimeSpan);
  629.   CLDate&    operator-=(const CLTimeSpan& TimeSpan);
  630.   CLDate&    operator++();
  631.   CLDate&    operator--();
  632.  
  633.  
  634.   //Overloaded Equality operators
  635.   BOOL operator==(CLDate& ld);
  636.   BOOL operator>(CLDate& ld);
  637.   BOOL operator>=(CLDate& ld);
  638.   BOOL operator<(CLDate& ld);
  639.   BOOL operator<=(CLDate& ld);
  640.   BOOL operator!=(CLDate& ld);
  641.  
  642.  
  643.   //Diagnostics / Debug
  644.   #ifdef _DEBUG
  645.   virtual void AssertValid() const;
  646.   virtual void Dump(CDumpContext& dc) const;
  647.   #endif
  648.  
  649.  
  650.   //Display
  651.   CString Format(const CString& sFormat) const;  //Format using a format specifier string
  652.   CString Format(DWORD dwFlags = 0) const;       //Format using the current NLSAPI settings
  653.   
  654.  
  655.   //Serialization
  656.   virtual void Serialize(CArchive& ar);
  657.  
  658.  
  659.   //streaming
  660.   friend AFX_EXT_API ostream&  operator<<(ostream& os, const CLDate& LDate);
  661.   friend AFX_EXT_API CArchive& operator<<(CArchive& ar, CLDate& LDate);
  662.   friend AFX_EXT_API CArchive& operator>>(CArchive& ar, CLDate& LDate);
  663.   
  664.          
  665. protected:
  666.   void CheckForValidLocalDate();
  667.   static void GetDefaultFormat();
  668.   BOOL DST();
  669.  
  670.   __int64   m_nSeconds;                 //Actual instance data
  671.   TimeFrame m_TimeFrame;                //What Time frame does this long date represent
  672.   BOOL      m_bValid;                   //Is this a valid instance
  673.  
  674.   static BOOL    sm_bDoAsserts;         //Do constructor asserts
  675.   static BOOL    sm_bIsDst;             //Used when determing if the date is in DST asserts in constructors / castings, otherwise sets date to invalid date
  676. };
  677.  
  678.  
  679.  
  680.  
  681.  
  682.  
  683.  
  684. #endif //__DATE_H__
  685.  
  686.