00001 #ifndef _DATE_H_
00002 #define _DATE_H_
00003
00004 #include <nds.h>
00005
00006 namespace WoopsiUI {
00007
00011 class Date {
00012 public:
00013
00020 inline Date(u8 day, u8 month, u16 year) {
00021 setDate(day, month, year);
00022 };
00023
00027 inline ~Date() { };
00028
00033 inline const char* getDayName() const { return _dayNames[_weekDay]; };
00034
00039 inline const char* getMonthName() const { return _monthNames[_month - 1]; };
00040
00046 inline const u8 getWeekDay() const { return _weekDay; };
00047
00052 inline const bool isLeapYear() const {
00053 return ((_year % 4 == 0) && ((_year % 100 != 0) || (_year % 400 == 0)));
00054 };
00055
00060 inline const u16 getYearDays() {
00061 if (isLeapYear()) return 366;
00062 return 365;
00063 }
00064
00069 const u8 getMonthDays() const;
00070
00075 void addYears(s16 years);
00076
00081 void addMonths(s16 months);
00082
00087 void addDays(s16 days);
00088
00093 inline const u8 getDay() const { return _day; };
00094
00099 inline const u8 getMonth() const { return _month; };
00100
00105 inline const u16 getYear() const { return _year; };
00106
00113 void setDate(u8 day, u8 month, u16 year);
00114
00118 bool operator==(const Date& date) const;
00119
00123 bool operator!=(const Date& date) const;
00124
00125 private:
00126 u8 _day;
00127 u8 _month;
00128 u16 _year;
00129 u8 _weekDay;
00130 static const char* _dayNames[7];
00131 static const char* _monthNames[12];
00138 const int getLeapCompensationValue() const;
00139
00143 void calculateWeekDay();
00144
00149 void setYear(u16 year);
00150
00156 void setMonth(u8 month);
00161 void setDay(u8 day);
00162 };
00163 }
00164
00165 #endif