From eb4ef0c3b5bd6d0e3fb158de3c19ef7ab2a8105c Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Tue, 23 Jul 2024 12:48:50 +0200 Subject: [PATCH] Allow adjustment of the step list by a tolerance of 5 minutes per step --- library/src/calculate_price.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/library/src/calculate_price.cpp b/library/src/calculate_price.cpp index 7a93a51..e6353d2 100644 --- a/library/src/calculate_price.cpp +++ b/library/src/calculate_price.cpp @@ -410,12 +410,14 @@ int CALCULATE_LIBRARY_API compute_next_timestep(parking_tariff_t *tariff, int cu maxStep = stepList[1] - stepList[0]; } int tolerance = (maxStep == -1) ? 5 : std::min(maxStep, 5); - if (std::abs(stepList[0] - currentTimeMinutes) <= tolerance) { - qCritical().noquote() - << QString(" compute_next_timestep() correction stepList[0]=%1 -> %2:") - .arg(stepList[0]).arg(currentTimeMinutes); - stepList[0] = currentTimeMinutes; - qCritical() << " compute_next_timestep() NEW timeSteps:" << stepList; + for (int i=0; i < stepList.size(); ++i) { + if (std::abs(stepList[i] - currentTimeMinutes) <= tolerance) { + qCritical().noquote() + << QString(" compute_next_timestep() correction stepList[%1]=%2 -> %3:") + .arg(i).arg(stepList[0]).arg(currentTimeMinutes); + stepList[i] = currentTimeMinutes; + qCritical() << " compute_next_timestep() NEW timeSteps:" << stepList; + } } int currentStepIndex = stepList.indexOf(currentTimeMinutes);