From 71e370308719e43732cdf76162eb9bcd3a65331f Mon Sep 17 00:00:00 2001 From: John Ralls Date: Sun, 20 Aug 2017 21:49:04 +0200 Subject: [PATCH] Use time64 GncDateTime constructor instead of struct tm constructor. It's substantially faster and we do a lot of time64->gdate conversions. --- libgnucash/engine/gnc-date.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libgnucash/engine/gnc-date.cpp b/libgnucash/engine/gnc-date.cpp index 9fe89ee829..8fb163c955 100644 --- a/libgnucash/engine/gnc-date.cpp +++ b/libgnucash/engine/gnc-date.cpp @@ -1336,11 +1336,12 @@ timespecToTime64 (Timespec ts) GDate timespec_to_gdate (Timespec ts) { GDate result; - gint day, month, year; g_date_clear (&result, 1); - gnc_timespec2dmy (ts, &day, &month, &year); - g_date_set_dmy (&result, day, static_cast(month), year); + GncDateTime time(ts.tv_sec); + auto date = time.date().year_month_day(); + g_date_set_dmy (&result, date.day, static_cast(date.month), + date.year); g_assert(g_date_valid (&result)); return result;