From 82da49efc2b1f5d65a7c00b1f8a5a1cb1511566d Mon Sep 17 00:00:00 2001 From: John Ralls Date: Sat, 18 Jul 2020 15:03:34 -0700 Subject: [PATCH] Bug 797858 - Transaction date is one day too early from... SWIFT MT940 import. GWEN_Date_ToLocalTime doesn't handle Daylight Savings Time correctly so extract the day, month, and year from the GWEN_DATE and use our own coversion function. --- gnucash/import-export/aqb/gnc-ab-utils.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/gnucash/import-export/aqb/gnc-ab-utils.c b/gnucash/import-export/aqb/gnc-ab-utils.c index de422da3aa..a049b3efe5 100644 --- a/gnucash/import-export/aqb/gnc-ab-utils.c +++ b/gnucash/import-export/aqb/gnc-ab-utils.c @@ -89,6 +89,14 @@ struct _GncABImExContextImport GData *tmp_job_list; }; +static inline time64 +gnc_gwen_date_to_time64 (const GWEN_DATE* date) +{ + return gnc_dmy2time64_neutral(GWEN_Date_GetDay(date), + GWEN_Date_GetMonth(date), + GWEN_Date_GetYear(date)); +} + void gnc_GWEN_Init(void) { @@ -571,11 +579,7 @@ gnc_ab_trans_to_gnc(const AB_TRANSACTION *ab_trans, Account *gnc_acc) } if (valuta_date) { -#ifdef AQBANKING6 - time64 secs = GWEN_Date_toLocalTime(valuta_date); -#else - time64 secs = GWEN_Time_toTime_t(valuta_date); -#endif + time64 secs = gnc_gwen_date_to_time64(valuta_date); xaccTransSetDatePostedSecsNormalized(gnc_trans, secs); } else @@ -1057,12 +1061,7 @@ bal_accountinfo_cb(AB_IMEXPORTER_ACCOUNTINFO *element, gpointer user_data) #endif if (ti) { -#ifdef AQBANKING6 - time64 secs = GWEN_Date_toLocalTime(ti); -#else - time64 secs = GWEN_Time_toTime_t(ti); -#endif - booked_tt = gnc_time64_get_day_neutral(secs); + booked_tt = gnc_gwen_date_to_time64(ti); } else {