4 * Created on: Dec 7, 2010
21 static const int CONST__DAYS_PER_MONTH[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
28 ltime = localtime(&wtime);
29 year = 1900 + ltime->tm_year;
30 month = ltime->tm_mon;
32 hour = ltime->tm_hour;
37 Date::Date(int year_param,
52 // TODO Auto-generated destructor stub
55 bool Date::is_leap_year() {
59 if ((year % 4 == 0) &&
60 (year % 400 == 0) || (year % 100 != 0)) {
66 void Date::printout() {
67 log_debug("%d-%02d-%02d %02d:%02d:%02d\n", year, month, day, hour, min, sec);
73 ret_val = new Date(this->year,
82 void Date::copy(Date *date) {
83 this->year = date->year;
84 this->month = date->month;
85 this->day = date->day;
86 this->hour = date->hour;
87 this->min = date->min;
88 this->sec = date->sec;
91 bool Date::before(Date date2) {
93 string s1 = this->to_string();
94 string s2 = date2.to_string();
97 if (s1.compare(s2) < 0) {
103 bool Date::equals(Date date2) {
107 if ((this->sec == date2.sec) &&
108 (this->min == date2.min) &&
109 (this->hour == date2.hour) &&
110 (this->day == date2.day) &&
111 (this->month == date2.month) &&
112 (this->year == date2.year)) {
118 void Date::tomorrow() {
122 if (day > CONST__DAYS_PER_MONTH[month - 1]) {
124 (is_leap_year() == true) &&
140 string Date::to_string() {
145 sprintf(buffer, "%016d%02d%02d%02d%02d%02d", year, month, day, hour, min, sec);