gnucash stable: Bug 798946 - start/end of current/last quarter have off-by-one error

John Ralls jralls at code.gnucash.org
Sat Feb 17 16:17:22 EST 2024


Updated	 via  https://github.com/Gnucash/gnucash/commit/266ae2a9 (commit)
	from  https://github.com/Gnucash/gnucash/commit/f5b7bf34 (commit)



commit 266ae2a931de6995b3f4e38fa32201a4a31ceab5
Author: John Ralls <jralls at ceridwen.us>
Date:   Sat Feb 17 12:47:04 2024 -0800

    Bug 798946 - start/end of current/last quarter have off-by-one error
    
    Calculating the quarter offset when the current month is less than the
    beginning month of the fiscal year was inverted.

diff --git a/libgnucash/engine/gnc-option-date.cpp b/libgnucash/engine/gnc-option-date.cpp
index 6fb28da550..68d4454653 100644
--- a/libgnucash/engine/gnc-option-date.cpp
+++ b/libgnucash/engine/gnc-option-date.cpp
@@ -529,8 +529,8 @@ gnc_relative_date_to_time64(RelativeDatePeriod period)
         case RelativeDateOffset::QUARTER:
         {
             auto delta = (now.tm_mon > acct_per.tm_mon ?
-                          now.tm_mon - acct_per.tm_mon :
-                           acct_per.tm_mon - now.tm_mon) % 3;
+                          ( now.tm_mon - acct_per.tm_mon) % 3 :
+                          3 - ((acct_per.tm_mon - now.tm_mon) % 3));
             now.tm_mon = now.tm_mon - delta;
         }
             [[fallthrough]];



Summary of changes:
 libgnucash/engine/gnc-option-date.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)



More information about the gnucash-changes mailing list