From 7b34971c8777e0f1326831d57f935304c2391e95 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Sun, 22 Sep 2024 16:15:52 -0700 Subject: [PATCH] Gnc-options-date: Make the accounting period struct tm empty... If the accounting period start-choice is anything but absolute instead of matching the accounting period month and day to the present month and day. The latter is a non-obvious hack that depends on gnc_accounting_period_fiscal_start() returning the present day if it's not set. --- libgnucash/engine/gnc-option-date.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/libgnucash/engine/gnc-option-date.cpp b/libgnucash/engine/gnc-option-date.cpp index 51d7c4a65ab..ee3c72b0d7a 100644 --- a/libgnucash/engine/gnc-option-date.cpp +++ b/libgnucash/engine/gnc-option-date.cpp @@ -23,6 +23,7 @@ #include "gnc-option-date.hpp" #include #include "gnc-datetime.hpp" +#include #include #include #include @@ -496,14 +497,10 @@ gnc_relative_date_to_time64(RelativeDatePeriod period) if (period == RelativeDatePeriod::TODAY) return static_cast(now_t); auto now{static_cast(now_t)}; - auto acct_per{static_cast(GncDateTime(gnc_accounting_period_fiscal_start()))}; - - if (acct_per.tm_mon == now.tm_mon && acct_per.tm_mday == now.tm_mday) - { - //No set accounting period, use the calendar year - acct_per.tm_mon = 0; - acct_per.tm_mday = 0; - } + struct tm acct_per{}; + if (gnc_prefs_get_bool (GNC_PREFS_GROUP_ACCT_SUMMARY, + GNC_PREF_START_CHOICE_ABS)) + acct_per = static_cast(GncDateTime(gnc_accounting_period_fiscal_start())); switch(reldate_offset(period)) {