X-Git-Url: http://pilppa.org/gitweb/?a=blobdiff_plain;f=src%2FDate.cc;h=d13d6d4798443fb9fd2c93875feb531289972e7e;hb=9a61860296f39594c2ae43b30f174281b7e5cb35;hp=6e8fdb6250b3d7e101a2e760cf176349a7cc52eb;hpb=6b8da0110c1dc3c720b6000b95b401b87e78d3f2;p=lib1wire.git diff --git a/src/Date.cc b/src/Date.cc index 6e8fdb6..d13d6d4 100644 --- a/src/Date.cc +++ b/src/Date.cc @@ -88,29 +88,35 @@ void Date::copy(Date *date) { sec = date->sec; } -bool Date::before(Date date2) { +bool Date::before(Date *date2) { bool ret_val; + string s1; + string s2; - string s1 = this->to_sortable_string(); - string s2 = date2.to_sortable_string(); ret_val = false; - if (s1.compare(s2) < 0) { - ret_val = true; + if (date2 != NULL) { + s1 = this->to_sortable_string(); + s2 = date2->to_sortable_string(); + if (s1.compare(s2) < 0) { + ret_val = true; + } } return ret_val; } -bool Date::equals(Date date2) { +bool Date::equals(Date *date2) { bool ret_val; ret_val = false; - if ((this->sec == date2.sec) && - (this->min == date2.min) && - (this->hour == date2.hour) && - (this->day == date2.day) && - (this->month == date2.month) && - (this->year == date2.year)) { - ret_val = true; + if (date2 != NULL) { + if ((this->sec == date2->sec) && + (this->min == date2->min) && + (this->hour == date2->hour) && + (this->day == date2->day) && + (this->month == date2->month) && + (this->year == date2->year)) { + ret_val = true; + } } return ret_val; }