gnucash stable: Bug 799506 - reconcile bad date pops to 1969
John Ralls
jralls at code.gnucash.org
Sat May 17 21:03:12 EDT 2025
Updated via https://github.com/Gnucash/gnucash/commit/910130c5 (commit)
from https://github.com/Gnucash/gnucash/commit/fc5ec5d3 (commit)
commit 910130c5009981986f886153bbf4b778ecb3a3ae
Author: John Ralls <jralls at ceridwen.us>
Date: Sat May 17 18:01:01 2025 -0700
Bug 799506 - reconcile bad date pops to 1969
Ensure that qof_scan_date always returns a valid year, month, and day
by converting the result of date scanning to a struct tm and
normalizing it.
diff --git a/libgnucash/engine/gnc-date.cpp b/libgnucash/engine/gnc-date.cpp
index 2302ae6295..d3851857d5 100644
--- a/libgnucash/engine/gnc-date.cpp
+++ b/libgnucash/engine/gnc-date.cpp
@@ -907,9 +907,16 @@ qof_scan_date_internal (const char *buff, int *day, int *month, int *year,
if (iyear < 100)
iyear += ((int) ((now_year + 50 - iyear) / 100)) * 100;
- if (year) *year = iyear;
- if (month) *month = imonth;
- if (day) *day = iday;
+ /* Fix up any goofy dates */
+ struct tm tm{};
+ tm.tm_year = iyear - 1900;
+ tm.tm_mon = imonth - 1;
+ tm.tm_mday = iday;
+ normalize_struct_tm(&tm);
+
+ if (year) *year = tm.tm_year + 1900;
+ if (month) *month = tm.tm_mon + 1;
+ if (day) *day = tm.tm_mday;
return(TRUE);
}
Summary of changes:
libgnucash/engine/gnc-date.cpp | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
More information about the gnucash-changes
mailing list