GnuCash
Contact   Instructions
Bug 797161 - first transaction with trn:date-posted on 1st day of month counted to previous month by graphs (due to timezone)
Summary: first transaction with trn:date-posted on 1st day of month counted to previou...
Status: RESOLVED OBSOLETE
Alias: None
Product: GnuCash
Classification: Unclassified
Component: Engine (show other bugs)
Version: 3.4
Hardware: PC Linux
: Normal normal
Target Milestone: ---
Assignee: core
QA Contact: core
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-30 12:11 EDT by Adam Lis
Modified: 2021-03-23 16:37 EDT (History)
4 users (show)

See Also:


Attachments

Description Adam Lis 2019-03-30 12:11:14 EDT
1st of all - used version of GnuCash:

$ apt-cache policy gnucash
gnucash:
  Installed: 1:3.4-0+bionic~ppa1
  Candidate: 1:3.4-0+bionic~ppa1
  Version table:
 *** 1:3.4-0+bionic~ppa1 500
        500 http://ppa.launchpad.net/sicklylife/gnucash/ubuntu bionic/main amd64 Packages
        100 /var/lib/dpkg/status

I'm using it in UTC+01:00 timezone:

$ date -Iminutes
2019-03-30T16:57+01:00

(after today's midnight it would be UTC+02:00)

***

Case is, I've opened .gnucash file created with version 2.6.3, however I do not believe import is case here. Just to mention.

In .gnucash file I have transactions that come from QIF files (were imported from QIFs), where QIF has only transaction date and no time.

For that reason all my transactions have field trn:date-posted in format:

  <trn:date-posted>
    <ts:date>2014-01-01 00:00:00 +0100</ts:date>
  </trn:date-posted>

Above transaction would appear in table view as done at 2014-01-01. Moreover, I have in same account 2 such transactions, that are are having above trn:date-posted.

It's clear above transaction has been taken 2013-12-31 23:00:00 UTC, which is 2014-01-01 00:00:00 UTC+1 (local time).

***

Where is problem?

Well, having 2 transactions in one account, both with trn:date-posted with value "<ts:date>2014-01-01 00:00:00 +0100</ts:date>", they behave so:

1) in table view on that account, both have date field "2014-01-01"

2) in graph created including that account, that is split monthly, it behave so:

2a) 1st transaction with "2014-01-01 00:00:00 +0100" is counted for month 2013-12
2b) 2nd and all next transaction with date "2014-01-01 00:00:00 +0100" are counted for month 2014-01

***

And this schema is valid for all other transactions, which in UTC are "in previous month" while in local timezone are "in current month".

My first thought was that this is timezone problem, so that graph is set to split by months based on UTC datetime. But this is occurring only for 1st such transaction in each account. All next ones with even same datetime are counted correctly.

***

Please let me know if I should prepare example .gnucash file.

Maybe this is expected behavior?
Comment 1 John Ralls 2019-03-30 12:30:32 EDT
If the QIF importer is setting posted-date to local midnight, that's the problem. Date-only times should be set to 10:59:00 UTC so that they'll be the right date in almost all timezones.
Comment 2 Adam Lis 2019-03-30 16:23:50 EDT
Thanks for reply.

So seems GnuCash in version 2.6.3 used to set times to local midnight when importing QIF files with only dates - all data in my file comes from imports.

I'm only wondering, why among few transactions being in month-1 when checking UTC and being in month+0 when checking local time, only 1st of them is counted to month-1 in graphs. This looks like a bug. For me it's not a problem, since I'm private user and for my transactions time is not important.

Then I need to check QIF import in 3.4, if it produces transactions with time set to 10:59:00 UTC.

And my existing file:

$ zcat gnucash-instance02.xml.gnucash | egrep -e "00:00:00 \+0[12]00"  | wc -l
12262

Would it be OK, to stream replace above values, e.g. by sed?
Comment 3 John Ralls 2019-03-30 16:59:04 EDT
The time fix was around 2.6.13 IIRC.
You don't want to change all instances of 00:00:00, some of them will be for 1970-01-01 which is time 0 and used to be used for "not a time".
Ideally you should use an XML facility like XSLT to change the times, but you can probably get away with an extended regex (use sed -E) like
   s;((19[89]|20[01])[0-9]-[01][0-9]-[0-3][0-9]) 00:00:00 \+[12]00;$1 10:59:00 +0000;

Make a backup first!

Note You need to log in before you can comment on or make changes to this bug.