pygnucash icon indicating copy to clipboard operation
pygnucash copied to clipboard

Timezones

Open dbrgn opened this issue 9 years ago • 1 comments

Gnucash exported the transactions using UTC time, while the Gnucash software is set to UTC+2.

Therefore transactions that occured on "2016/08/02" were exported as "2016/08/01 22:00" and interpreted as "2016/08/01".

I used this hack in gnucash.py to adjust:

import calendar

# ...

    def parse_time(time):
        dt = datetime.strptime(time, "%Y%m%d%H%M%S")                                                
        timestamp = calendar.timegm(dt.timetuple()) + 7200                                                               
        return datetime.utcfromtimestamp(timestamp)         

Maybe this could be made configurable using a CLI switch?

dbrgn avatar Sep 01 '16 22:09 dbrgn

I cannot reproduce this behavior with gnucash 2.6.18 in MacOS: i.e. when I add a transaction on 1/2/2013 (US locale) in gnucash, I see "20130102105900" in the database irrespective of my timezone settings. Similarily strptime used without a timezone modifier here should give us what they call a "naive object" in the documentation that should just print the same way it was parsed I think.

Maybe they changed the behavior in newer gnucash versions? (or does the mac version diregard the timezones?)

MatzeB avatar Dec 22 '17 14:12 MatzeB