home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ool_main.zip / ool / include / xdate.h < prev    next >
Text File  |  1998-04-15  |  3KB  |  72 lines

  1. #ifndef __OOL_XDATE_H__
  2. #define __OOL_XDATE_H__
  3.  
  4. /*===========================================================================*/
  5. /* OOL ------------------- the Open Object Library ------------------- r 1.0 */
  6. /*===========================================================================*/
  7. /*                              class: XDate                                 */
  8. /*                       derived from: XObject                               */
  9. /*                        last update: 1/97                                  */
  10. /*                      programmed by: Stefan von Brauk (sbrauk@gwdg.de)     */
  11. /*===========================================================================*/
  12.  
  13.  
  14. #include "xobject.h"
  15. #include "string.h"
  16.  
  17. typedef struct XDateStructure{
  18.    UCHAR days;
  19.    UCHAR months;
  20.    USHORT years;
  21.    UCHAR weekday;
  22.    USHORT dayOfYear;
  23. } XDateStruct;
  24.  
  25.  
  26. class XString;
  27.  
  28.  
  29. class _export_ XDate: public XObject
  30. {
  31.       friend class XContainerObject;
  32.       friend class XIO;
  33.       friend class XFileInfo;
  34.    private:
  35.       XDateStructure d;
  36.    public:
  37.       XDate( const UCHAR day=0, const UCHAR month=0, const SHORT year=0, const UCHAR weekd=0, const USHORT dayOfYear=0);
  38.       XDate( const XDate& da) { memcpy(&d, &da.d, sizeof(d));}
  39.       virtual ~XDate() {;}
  40.       BOOL AddDays(const SHORT days);
  41.       SHORT Compare(const XDate*d) const;
  42.       void GetCurrentDate( void);
  43.       static XDate GetDateFromDay( const USHORT days, const USHORT years);
  44.       UCHAR GetDays( void ) const { return d.days; }
  45.       UCHAR GetDaysOfMonth() const;
  46.       USHORT GetDayOfYear(void) const ;//{ return d.dayOfYear; }
  47.       UCHAR GetMonths( void ) const { return d.months; }
  48.       ULONG GetTotalDays() const;
  49.       USHORT GetTotalDaysOfYear() const;
  50.       USHORT GetWeek() const;
  51.       XDate GetWeekBegin() const;
  52.       UCHAR GetWeekDay() const;
  53.       USHORT GetYears( void ) const { return d.years; }
  54.       void Format( XString * buffer, const char * format) const;
  55.       USHORT XDate::IsCeremon();
  56.       BOOL IsLeapYear() const;
  57.       BOOL IsLegalDate() const;
  58.       void SetDays( const UCHAR days) { d.days = days; }
  59.       void SetMonths( const UCHAR months) { d.months = months; }
  60.       void SetWeekDay( const UCHAR weekd) { d.weekday = weekd; }
  61.       void SetYears( const USHORT years) { d.years = years; }
  62.       BOOL Set(const char * s, SHORT format);
  63.       XDate operator = (const XDate& da) { memcpy(&d, &da.d, sizeof(d)); return *this; }
  64.       BOOL operator == (const XDate &da) { return ( Compare( &da ) == 0 ? TRUE : FALSE); }
  65.       BOOL operator != (const XDate &da) { return ( Compare( &da ) != 0 ? TRUE : FALSE); }
  66.       BOOL operator > (const XDate &da) { return ( Compare( &da ) > 0 ? TRUE : FALSE); }
  67.       BOOL operator < (const XDate& da) { return( Compare(&da) < 0 ? TRUE : FALSE); }
  68. };
  69.  
  70.  
  71. #endif
  72.