From 6fcc4e9af18b99e4607f8d1f83d4e4dcb3958830 Mon Sep 17 00:00:00 2001 From: Phil Olynyk Date: Thu, 18 Jul 2019 21:16:05 -0400 Subject: [PATCH] Add number of years times 12 to lastmonth - then trim to 12 max --- oscar/statistics.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/oscar/statistics.cpp b/oscar/statistics.cpp index e38a3b3f..9bc5ea95 100644 --- a/oscar/statistics.cpp +++ b/oscar/statistics.cpp @@ -1068,14 +1068,16 @@ QString Statistics::GenerateCPAPUsage() if (p_profile->general->statReportMode() == STAT_MODE_MONTHLY) { int firstMonth = firstcpap.month(); int lastMonth = lastcpap.month(); - if (lastMonth <= firstMonth && firstcpap.year() != lastcpap.year()) - lastMonth += 12; // handle time extending to next year + int years = lastcpap.year() - firstcpap.year(); + if (lastMonth <= firstMonth) + lastMonth += (12 * years); // handle time extending to next year number_periods = lastMonth - firstMonth + 1; if (number_periods < 1) { qDebug() << "*** Begin" << firstcpap << "beginMonth" << firstMonth << "lastMonth" << lastMonth << "periods" << number_periods; number_periods = 1; } + qDebug() << "Number of months for stats (trim to 12 max)" << number_periods; // But not more than one year if (number_periods > 12) { number_periods = 12;