GnuCash
Contact   Instructions
Bug 796893 - invoice.GetDatePosted() and other date related functions returns strange values for uninitalised dates
Summary: invoice.GetDatePosted() and other date related functions returns strange valu...
Status: RESOLVED FIXED
Alias: None
Product: GnuCash
Classification: Unclassified
Component: Python Bindings (show other bugs)
Version: git-maint
Hardware: PC Linux
: Normal normal
Target Milestone: ---
Assignee: core
QA Contact: core
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-06 15:50 EDT by Tom Lofts
Modified: 2018-10-06 18:03 EDT (History)
2 users (show)

See Also:


Attachments
Example Python script reproducing issue (913 bytes, text/x-python)
2018-10-06 15:50 EDT, Tom Lofts
no flags Details
Proposed patch to resolve this issue (1.10 KB, patch)
2018-10-06 15:51 EDT, Tom Lofts
jralls: committed+
Details

Description Tom Lofts 2018-10-06 15:50:19 EDT
Created attachment 373014 [details]
Example Python script reproducing issue

Hi all,

I've been looking at invoice.GetDatePosted() for newly created invoices where the posted date hasn't been initialised and rather than returning None or 0000-00-00 00:00 they're returning very large invalid times.

Please refer to the attachment which reproduces the issue printing an invalid date.

I believe the issue is e.g. in gncInvoice.c invoice->date_posted is initialised to INT64_MAX which is sent though to Python as a datetime.

My suggested fix is to update the time64.i to return Py_None if the time matches INT64_MAX and I've attached a patch which does this and rerunning the test script now prints 'None'.

If you feel this is a reasonable solution I can submit a pull request if required.

Kind regards,

Tom
Comment 1 Tom Lofts 2018-10-06 15:51:23 EDT
Created attachment 373015 [details]
Proposed patch to resolve this issue
Comment 2 John Ralls 2018-10-06 18:02:58 EDT
Comment on attachment 373015 [details]
Proposed patch to resolve this issue

Nah, it's a simple enough patch, I just pasted it in. It would be nice if next time you create a proper patch with `git format-patch`, though.

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