]> pilppa.org Git - lib1wire.git/blobdiff - src/Date.cc
Use pointers in date comparison functions.
[lib1wire.git] / src / Date.cc
index 6e8fdb6250b3d7e101a2e760cf176349a7cc52eb..d13d6d4798443fb9fd2c93875feb531289972e7e 100644 (file)
@@ -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;
 }