User Tools

Site Tools


brain:brain.date.h

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

brain:brain.date.h [2017/01/19 16:19] – created peterbrain:brain.date.h [2017/01/19 20:10] (current) – removed peter
Line 1: Line 1:
-date.h 
- 
-<code cpp> 
-#ifndef __SHAREWIZ_DATE_H__ 
-#define __SHAREWIZ_DATE_H__ 
- 
-// Jan 1 4713 BC is used by astronomers as their starting point. 
-// Monday Jan 1, 1 AD.  //   1721425 days diff from Jan 1 4713 BC. 
-// 1992 and 2000 were leapyears.  1800 was not. 
- 
-const int Sun = 0; 
-const int Mon = Sun + 1; 
-const int Tue = Mon + 1; 
-const int Wed = Tue + 1; 
-const int Thu = Wed + 1; 
-const int Fri = Thu + 1; 
-const int Sat = Fri + 1; 
- 
- 
-class Date 
-{ 
-protected: 
-  long date; 
- 
-public: 
-  Date(); 
- 
-  friend long operator- (const Date& a, const Date& b); 
-  friend Date operator+ (const Date& a, const long& b); 
- 
-  long getDate(); 
- 
-  void setDate(long _date); 
-  void setWeekdayOnOrBefore(int _weekday); 
-}; 
- 
-   
-class DateGregorian : public Date 
-{ 
-protected: 
-  int year; 
-  int month; 
-  int day; 
- 
-  bool isLeapYear(int _year) 
-  { 
-    if ((_year % 400) == 0) return true; 
-    if ((_year % 100) == 0) return false; 
-    if ((_year % 4) == 0) return true; 
-    return false; 
-  } 
- 
-  int daysInMonth(int _year, int _month) 
-  { 
-    int m[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; 
-    if (_month == 2 && isLeapYear(_year)) 
-      return 29; 
-    return m[_month - 1]; 
-  } 
- 
-public: 
-  DateGregorian(); 
-  DateGregorian(int _year, int _month, int _day); 
-  DateGregorian(Date _date); 
- 
-  int getDayOfWeek(); 
- 
-  void setDate(int _year, int _month, int _day); 
-  void setDate(long _date); 
-  void print(); 
-  void easter(int _year); 
-}; 
- 
- 
-class DateJulian : public DateGregorian 
-{ 
-  /* 
-protected: 
-  int year; 
-  int month; 
-  int day; 
-  */ 
-  bool isLeapYear(int _year) 
-  { 
-    if ((_year % 4) == 0) return true; 
-    return false; 
-  } 
- 
-public: 
-  DateJulian(); 
-  DateJulian(int _year, int _month, int _day); 
-  DateJulian(Date d); 
- 
-  void setDate(int _year, int _month, int _day); 
-  void setDate(long d); 
- 
-  //void print(); 
-  void easter(int _year); 
-}; 
- 
- 
- 
-#endif 
-</code> 
  
brain/brain.date.h.1484842758.txt.gz · Last modified: 2020/07/15 09:30 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki