Woopsi 1.0
GUI Framework for Nintendo DS Homebrew

date.h

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 
00083                 void addMonths(s16 months);
00084 
00089                 void addDays(s16 days);
00090 
00095                 inline const u8 getDay() const { return _day; };
00096 
00101                 inline const u8 getMonth() const { return _month; };
00102 
00107                 inline const u16 getYear() const { return _year; };
00108 
00115                 void setDate(u8 day, u8 month, u16 year);
00116 
00120                 bool operator==(const Date& date) const;
00121 
00125                 bool operator!=(const Date& date) const;
00126 
00127         private:
00128                 u8 _day;                                                                                
00129                 u8 _month;                                                                              
00130                 u16 _year;                                                                              
00131                 u8 _weekDay;                                                                    
00132                 static const WoopsiString _dayNames[7];                 
00133                 static const WoopsiString _monthNames[12];              
00140                 const int getLeapCompensationValue() const;
00141 
00145                 void calculateWeekDay();
00146 
00151                 void setYear(u16 year);
00152 
00158                 void setMonth(u8 month);
00164                 void setDay(u8 day);
00165         };
00166 }
00167 
00168 #endif