00001 #ifndef _DATE_H_ 00002 #define _DATE_H_ 00003 00004 #include <nds.h> 00005 #include "woopsistring.h" 00006 00007 namespace WoopsiUI { 00008 00012 class Date { 00013 public: 00014 00021 inline Date(u8 day, u8 month, u16 year) { 00022 setDate(day, month, year); 00023 }; 00024 00028 inline ~Date() { }; 00029 00034 inline const WoopsiString& getDayName() const { return _dayNames[_weekDay]; }; 00035 00040 inline const WoopsiString& getMonthName() const { return _monthNames[_month - 1]; }; 00041 00047 inline const u8 getWeekDay() const { return _weekDay; }; 00048 00053 inline const bool isLeapYear() const { 00054 return ((_year % 4 == 0) && ((_year % 100 != 0) || (_year % 400 == 0))); 00055 }; 00056 00061 inline const u16 getYearDays() { 00062 if (isLeapYear()) return 366; 00063 return 365; 00064 } 00065 00070 const u8 getMonthDays() const; 00071 00076 void addYears(s16 years); 00077 00082 void addMonths(s16 months); 00083 00088 void addDays(s16 days); 00089 00094 inline const u8 getDay() const { return _day; }; 00095 00100 inline const u8 getMonth() const { return _month; }; 00101 00106 inline const u16 getYear() const { return _year; }; 00107 00114 void setDate(u8 day, u8 month, u16 year); 00115 00119 bool operator==(const Date& date) const; 00120 00124 bool operator!=(const Date& date) const; 00125 00126 private: 00127 u8 _day; 00128 u8 _month; 00129 u16 _year; 00130 u8 _weekDay; 00131 static const WoopsiString _dayNames[7]; 00132 static const WoopsiString _monthNames[12]; 00139 const int getLeapCompensationValue() const; 00140 00144 void calculateWeekDay(); 00145 00150 void setYear(u16 year); 00151 00157 void setMonth(u8 month); 00162 void setDay(u8 day); 00163 }; 00164 } 00165 00166 #endif