From 610c9351915399a3ae997618de36510c833aff28 Mon Sep 17 00:00:00 2001 From: Seeker4 Date: Tue, 11 Jun 2019 06:28:34 -0700 Subject: [PATCH] Correct error in calculating number of periods in monthly report. --- oscar/statistics.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/oscar/statistics.cpp b/oscar/statistics.cpp index e3cea829..dd7fc6a3 100644 --- a/oscar/statistics.cpp +++ b/oscar/statistics.cpp @@ -1011,13 +1011,14 @@ QString Statistics::GenerateHTML() // Compute number of monthly periods for a monthly rather than standard time distribution int number_periods = 0; if (p_profile->general->statReportMode() == STAT_MODE_MONTHLY) { - QDate beginDate = qMax(firstcpap, lastcpap.addYears(-1)); - int beginMonth = beginDate.month(); + int firstMonth = firstcpap.month(); int lastMonth = lastcpap.month(); - if (lastMonth < beginMonth) lastMonth += 12; // handle time extending to next year - number_periods = lastMonth - beginMonth + 1; + if (lastMonth <= firstMonth && firstcpap.year() != lastcpap.year()) + lastMonth += 12; // handle time extending to next year + number_periods = lastMonth - firstMonth + 1; + if (number_periods < 1) { - qDebug() << "*** Begin" << beginDate << "beginMonth" << beginMonth << "lastMonth" << lastMonth << "periods" << number_periods; + qDebug() << "*** Begin" << firstcpap << "beginMonth" << firstMonth << "lastMonth" << lastMonth << "periods" << number_periods; number_periods = 1; } // But not more than one year