Use time64 GncDateTime constructor instead of struct tm constructor.

It's substantially faster and we do a lot of time64->gdate conversions.
This commit is contained in:
John Ralls 2017-08-20 21:49:04 +02:00
parent f7ce8bcbb3
commit 71e3703087

View File

@ -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<GDateMonth>(month), year);
GncDateTime time(ts.tv_sec);
auto date = time.date().year_month_day();
g_date_set_dmy (&result, date.day, static_cast<GDateMonth>(date.month),
date.year);
g_assert(g_date_valid (&result));
return result;