X-Git-Url: http://pilppa.org/gitweb/?a=blobdiff_plain;f=src%2FDate.cc;h=e45b544fc6073d40ba431f2c6eeb0d1693cc4edf;hb=af26b84b20b6d9d0e0ce690e8011a037e87dc5c8;hp=86b2cdc82a73bd28179ef36d8e9532f6dee9b0f7;hpb=af341b7dfafac0912f513879565ebd856aa77915;p=lib1wire.git diff --git a/src/Date.cc b/src/Date.cc index 86b2cdc..e45b544 100644 --- a/src/Date.cc +++ b/src/Date.cc @@ -136,7 +136,7 @@ bool Date::before_or_equal_month(Date *date2) { string s2; ret_val = false; - if (this->year < date2->month) { + if (this->year < date2->year) { ret_val = true; } else { @@ -212,7 +212,20 @@ bool Date::before_or_equal(Date *date2) { return ret_val; } -void Date::tomorrow() { +void Date::next_hour() { + sec = 0; + min = 0; + hour++; + if (hour < 0) { + hour = 0; + } + if (hour >= 24) { + hour = 0; + next_day(); + } +} + +void Date::next_day() { if ((month > 0) && (month <= 12)) { day++; @@ -234,17 +247,27 @@ void Date::tomorrow() { } } -void Date::next_hour() { - if ((hour >= 0) && - (hour <= 24)) { - hour++; - if (hour > 24) { - hour = 0; - tomorrow(); - } +void Date::next_month() { + sec = 0; + min = 0; + hour = 0; + day = 1; + month++; + if (month > 12) { + month = 1; + 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; @@ -255,13 +278,13 @@ void Date::inc_minutes(int minutes) { 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; @@ -270,7 +293,7 @@ void Date::inc_minutes(int minutes) { hour++; if (hour > 24) { hour = 0; - tomorrow(); + next_day(); } } }