string s2;
ret_val = false;
- if (this->year < date2->month) {
+ if (this->year < date2->year) {
ret_val = true;
}
else {
return ret_val;
}
-void Date::tomorrow() {
- if ((month > 0) &&
- (month <= 12)) {
- day++;
- if (day > CONST__DAYS_PER_MONTH[month - 1]) {
- if ((month == 2) &&
- (is_leap_year() == true) &&
- (day == 29)) {
- // ok
- }
- else {
- day = 1;
- month++;
- if (month > 12) {
- year++;
- month = 1;
- }
- }
- }
+void Date::next_second() {
+ if (sec < 59) {
+ sec++;
+ }
+ else {
+ next_min();
+ }
+}
+
+void Date::next_min() {
+ if (min < 59) {
+ sec = 0;
+ min++;
+ }
+ else {
+ next_hour();
}
}
void Date::next_hour() {
- if ((hour >= 0) &&
- (hour <= 24)) {
+ hour++;
+ if (hour < 23) {
+ sec = 0;
+ min = 0;
hour++;
- if (hour > 24) {
+ }
+ else {
+ next_day();
+ }
+}
+
+void Date::next_day() {
+ if ((month > 0) &&
+ (month <= 12)) {
+ if ((day < CONST__DAYS_PER_MONTH[month - 1]) ||
+ ((month == 2) &&
+ (is_leap_year() == true) &&
+ (day == 28))) {
+ sec = 0;
+ min = 0;
hour = 0;
- tomorrow();
+ day++;
+ }
+ else {
+ next_month();
}
}
}
+void Date::next_month() {
+ if (month < 12) {
+ sec = 0;
+ min = 0;
+ hour = 0;
+ day = 1;
+ month++;
+ }
+ else {
+ next_year();
+ }
+}
+
+void Date::next_year() {
+ sec = 0;
+ min = 0;
+ hour = 0;
+ day = 1;
+ month = 1;
+ year++;
+}
+
void Date::inc_minutes(int minutes) {
int day_c;
int hour_c;
hour_c = minutes / 60;
minutes = minutes - hour_c * 60;
for (ii = 0; ii < day_c; ii++) {
- tomorrow();
+ next_day();
}
for (ii = 0; ii < hour_c; ii++) {
hour++;
if (hour > 24) {
hour = 0;
- tomorrow();
+ next_day();
}
}
min = min + minutes;
hour++;
if (hour > 24) {
hour = 0;
- tomorrow();
+ next_day();
}
}
}