From aeb2e65ff163f72f1cfb12422378628de58bed89 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Tue, 12 Dec 2017 11:50:24 -0800 Subject: [PATCH] Fix posted-date scrub incrementing the day in central pacific timezones. --- libgnucash/engine/Transaction.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libgnucash/engine/Transaction.c b/libgnucash/engine/Transaction.c index b6c92647bd..811100d1a0 100644 --- a/libgnucash/engine/Transaction.c +++ b/libgnucash/engine/Transaction.c @@ -2424,7 +2424,20 @@ xaccTransGetDatePostedGDate (const Transaction *trans) if (G_VALUE_HOLDS_BOXED (&v)) result = *(GDate*)g_value_get_boxed (&v); if (! g_date_valid (&result)) - result = timespec_to_gdate(xaccTransRetDatePostedTS(trans)); + { + /* Well, this txn doesn't have a GDate saved in a + * slot. Avoid getting the date in the local TZ by + * converting to UTC before generating the + * date. (timespec_to_gdate doesn't do this so don't use + * it. + */ + time64 time = xaccTransGetDate(trans); + struct tm *stm = gnc_gmtime(&time); + g_date_set_dmy(&result, stm->tm_mday, + (GDateMonth)(stm->tm_mon + 1), + stm->tm_year + 1900); + free(stm); + } } return result; }