4 * Created on: Dec 7, 2010
19 static const int CONST__DAYS_PER_MONTH[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
26 ltime = localtime(&wtime);
27 year = ltime->tm_year;
28 month = ltime->tm_mon;
30 hour = ltime->tm_hour;
35 Date::Date(int year_param,
50 // TODO Auto-generated destructor stub
53 bool Date::is_leap_year() {
57 if ((year % 4 == 0) &&
58 (year % 400 == 0) || (year % 100 != 0)) {
64 void Date::printout() {
65 cout << "date: " << year << " " << month << " " << day << " " << hour << " " << min << " " << sec << endl;
71 ret_val = new Date(this->year,
80 void Date::copy(Date *date) {
81 this->year = date->year;
82 this->month = date->month;
83 this->day = date->day;
84 this->hour = date->hour;
85 this->min = date->min;
86 this->sec = date->sec;
89 bool Date::before(Date date2) {
91 string s1 = this->to_string();
92 string s2 = date2.to_string();
95 if (s1.compare(s2) < 0) {
101 bool Date::equals(Date date2) {
105 if ((this->sec == date2.sec) &&
106 (this->min == date2.min) &&
107 (this->hour == date2.hour) &&
108 (this->day == date2.day) &&
109 (this->month == date2.month) &&
110 (this->year == date2.year)) {
116 void Date::tomorrow() {
120 if (day > CONST__DAYS_PER_MONTH[month - 1]) {
122 (is_leap_year() == true) &&
138 string Date::to_string() {
143 sprintf(buffer, "%016d%02d%02d%02d%02d%02d", year, month, day, hour, min, sec);