[GNC-dev] Bug 796725

John Ralls jralls at ceridwen.us
Tue Aug 14 11:02:50 EDT 2018



> On Aug 14, 2018, at 6:55 AM, Robert Fewell <14ubobit at gmail.com> wrote:
> 
> I have been looking at this one and know what is wrong but not sure if my
> fix is valid.
> 
> It is to do with searching for transactions by posted date and returning
> the wrong number of transactions for the required filter option.
> 
> When the date entered in the GtkEntry, gnc_date_edit_get_date returns the
> time64 but at 12:00:00 am for that day.
> 
> Looking at the transaction posted date in my Xml file they are at
> '2018-01-01 10:59:00 +0000'
> 
> I can fix this in search-date.c by changing the two occurrences of
> gnc_date_edit_get_date to some thing like this...
> 
>        time64 temp = gnc_date_edit_get_date (GNC_DATE_EDIT (priv->entry));
>        struct tm * temp_tm = gnc_localtime (&temp);
> 
>        fi->tt = gnc_dmy2time64_neutral (temp_tm->tm_mday, temp_tm->tm_mon
> + 1, temp_tm->tm_year + 1900);
>        gnc_tm_free (temp_tm);
> 
> but this would affect all date searches in transactions, invoices and bills.
> 
> Should all dates be at this neutral time so it does not matter ?

Bob,

I think all search dates should be “open” intervals, meaning that if you search from 1 - 31 January, the result set should include transactions on both 1 January and 31 January as well as everything in between. The best way to accomplish this is to use gnc_dmy2time64() for the beginning of the search and gnc_dmy2time64_end() for the end of the search: The former returns 00:00:00 on the day and the latter to 23:59:59.

Transaction *posted* dates created with 2.6.12 or so and later are set to 10:59:00 UTC using gnc_dmy2time64_neutral() unless the user is in one of the “edge” timezones, -12, +13, or +14, in which cases the time is offset to keep the time in the same local day. Other dates, e.g. date_entered and date_reconciled, are set to the actual time that the action occurred, usually using gnc_time().

Regards,
John Ralls



More information about the gnucash-devel mailing list