Skip to content

Commit

Permalink
Gnc-options-date: Make the accounting period struct tm empty...
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jralls committed Sep 22, 2024
1 parent c584337 commit 7b34971
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions libgnucash/engine/gnc-option-date.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "gnc-option-date.hpp"
#include <array>
#include "gnc-datetime.hpp"
#include <gnc-prefs.h>
#include <iostream>
#include <cassert>
#include <algorithm>
Expand Down Expand Up @@ -496,14 +497,10 @@ gnc_relative_date_to_time64(RelativeDatePeriod period)
if (period == RelativeDatePeriod::TODAY)
return static_cast<time64>(now_t);
auto now{static_cast<tm>(now_t)};
auto acct_per{static_cast<tm>(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<tm>(GncDateTime(gnc_accounting_period_fiscal_start()));

switch(reldate_offset(period))
{
Expand Down

0 comments on commit 7b34971

Please sign in to comment.