home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snipps97.zip / DATE.HPP < prev    next >
C/C++ Source or Header  |  1997-07-05  |  4KB  |  119 lines

  1. .I 0 1
  2. // +++Date last modified: 05-Jul-1997
  3. .D 1 1
  4. .I 24 101
  5.       enum month {
  6.             jan = 1, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec
  7.       };
  8.  
  9.       enum week_day {
  10.             mon = 1, tue, wed, thu, fri, sat, sun
  11.       };
  12.  
  13.       enum moon_phase {
  14.             new_moon, waxing_crescent, first_quater, waxing_gibbous,
  15.             full_moon, waning_gibbous, third_quater, waning_crescent
  16.       };
  17.  
  18.       zDate();
  19.       zDate(month month, int day, int year);
  20.       zDate(int dayOfYear, int year);
  21.       zDate(const zDate &aDate);
  22.       zDate(ulong nDayNumber);
  23.       zDate(const struct tm *date);
  24.  
  25.       zDate             AddMonths(int nMonths) const;
  26.       zDate             AddWeeks(int nWeeks) const;
  27.       zDate             AddYears(int nYears) const;
  28.       int               Age(const zDate &aDate) const;
  29.       zDate             BeginDST() const;
  30.       static zDate      BeginDST(int aYear);
  31.       int               Day() const;
  32.       ulong             DayNumber() const;
  33.       week_day          DayOfWeek() const;
  34.       int               DayOfYear() const;
  35.       int               DaysInMonth() const;
  36.       static int        DaysInMonth(month aMonth, int aYear);
  37.       int               DaysInYear() const;
  38.       static int        DaysInYear(int year);
  39.       zDate             Easter() const;
  40.       static zDate      Easter(int year);
  41.       zDate             EndDST() const;
  42.       static zDate      EndDST(int aYear);
  43.       Boolean           IsDST() const;
  44.       static Boolean    IsDST(const zDate &date);
  45.       Boolean           IsLeapYear() const;
  46.       static Boolean    IsLeapYear(int year);
  47.       Boolean           IsValid() const;
  48.       static Boolean    IsValid(month aMonth, int aDay, int aYear);
  49.       month             Month() const;
  50.       moon_phase        MoonPhase() const;
  51.       static moon_phase MoonPhase(const zDate &date);
  52.                                 operator long() const;
  53.       Boolean           operator!=(const zDate &aDate) const;
  54.       zDate             operator+(int nDays) const;
  55.       zDate             operator+(long nDays) const;
  56.       zDate             operator++();
  57.       zDate             operator++(int);
  58.       zDate&            operator+=(int nDays);
  59.       zDate&            operator+=(long nDays);
  60.       long              operator-(const zDate &aDate) const;
  61.       zDate             operator-(int nDays) const;
  62.       zDate             operator-(long nDays) const;
  63.       zDate             operator--();
  64.       zDate             operator--(int);
  65.       zDate&            operator-=(int nDays);
  66.       zDate&            operator-=(long nDays);
  67.       Boolean           operator<(const zDate &aDate) const;
  68.       Boolean           operator<=(const zDate &aDate) const;
  69.       zDate&            operator=(const zDate &aDate);
  70.       Boolean           operator==(const zDate &aDate) const;
  71.       Boolean           operator>(const zDate &aDate) const;
  72.       Boolean           operator>=(const zDate &aDate) const;
  73.       char              operator[](int index) const;
  74.       static void       SetBeginDST(month aMonth, week_day aWeekDay);
  75.       static void       SetEndDST(month aMonth, week_day aWeekDay);
  76.       static zDate      Today();
  77.       int               WeekOfMonth() const;
  78.       int               WeekOfYear() const;
  79.       int               WeeksInYear() const;
  80.       static int        WeeksInYear(int year);
  81.       int               Year() const;
  82.  
  83.       // Pope Gregor XIII's reform cancelled 10 days:
  84.       // the day after Oct 4 1582 was Oct 15 1582
  85.       static const int      ReformYear;
  86.       static const month    ReformMonth;
  87.       static const ulong    ReformDayNumber;
  88.  
  89. protected:
  90.       // Daylight Savings Time Month and Day of Week
  91.       static month    BeginDSTMonth;
  92.       static week_day BeginDSTDay;
  93.       static month    EndDSTMonth;
  94.       static week_day EndDSTDay;
  95.  
  96. protected:
  97.       zDate Set(month aMonth, int aDay, int aYear);
  98.       ulong MakeDayNumber() const;
  99.       void  FromDayNumber(ulong nDayNumber);
  100.  
  101. private:
  102.       month m_month;
  103.       int   m_day;
  104.       int   m_year;
  105.       ulong m_dayno;
  106. .D 25 101
  107. .I 134 1
  108.       return m_year;
  109. .D 135 1
  110. .I 140 1
  111.       return m_day;
  112. .D 141 1
  113. .I 146 1
  114.       return m_month;
  115. .D 147 1
  116. .I 152 1
  117.       return m_dayno;
  118. .D 153 1
  119.