X-Git-Url: http://pilppa.org/gitweb/?a=blobdiff_plain;f=src%2FStoreDay.cc;h=fb5c1757f3b8f20575b49d21478c3b494d29a832;hb=af26b84b20b6d9d0e0ce690e8011a037e87dc5c8;hp=8d35952f5a3321f60501172fdbdc40445f989b58;hpb=af341b7dfafac0912f513879565ebd856aa77915;p=lib1wire.git diff --git a/src/StoreDay.cc b/src/StoreDay.cc index 8d35952..fb5c175 100644 --- a/src/StoreDay.cc +++ b/src/StoreDay.cc @@ -436,10 +436,12 @@ plp::DataRange *StoreDay::get_max_or_min(EnumSummaryPeriod period_type_param, bo date = data->get_date(); if ((ii <= (row_count -1)) && ((frq_sec == -1) || (date.before(limit_d)))) { + int changed = 0; if (max == true) { for (jj = 0; jj < col_count; jj++) { if (calc->value_arr[jj] < data->value_arr[jj]) { calc->value_arr[jj] = data->value_arr[jj]; + changed = 1; } } } @@ -447,9 +449,16 @@ plp::DataRange *StoreDay::get_max_or_min(EnumSummaryPeriod period_type_param, bo for (jj = 0; jj < col_count; jj++) { if (data->value_arr[jj] < calc->value_arr[jj]) { calc->value_arr[jj] = data->value_arr[jj]; + changed = 1; } } } + if (changed == 1) { + Date new_date; + + new_date = data->get_date(); + calc->set_date(&new_date); + } } if ((ii >= (row_count -1)) || ((frq_sec != -1) && (date.before(limit_d) == false))) { @@ -525,17 +534,19 @@ DataRange *StoreDay::get_oldest_and_newest_data(string fname_param) { } else { in.open(fname_param.c_str()); - while (in.eof() == false) { - getline(in, line); - if (line.empty() == false) { - if (o_data == NULL) { - o_data = Data::parse_string(line); + if (in.is_open() == true) { + while (in.eof() == false) { + getline(in, line); + if (line.empty() == false) { + if (o_data == NULL) { + o_data = Data::parse_string(line); + } + prev_line = line; } - prev_line = line; } - } - if (prev_line.empty() == false) { - n_data = Data::parse_string(prev_line); + if (prev_line.empty() == false) { + n_data = Data::parse_string(prev_line); + } } } }