gnucash maint: Bug 796893 - invoice.GetDatePosted() and other date related...

John Ralls jralls at code.gnucash.org
Sat Oct 6 18:01:57 EDT 2018


Updated	 via  https://github.com/Gnucash/gnucash/commit/820cd842 (commit)
	from  https://github.com/Gnucash/gnucash/commit/7a4b06c4 (commit)



commit 820cd842f19c4ed1b93777f8ec21fa76ff2c3ac1
Author: Tom Lofts <dev at loftx.co.uk>
Date:   Sat Oct 6 14:59:52 2018 -0700

    Bug 796893 - invoice.GetDatePosted() and other date related...
    
    functions returns strange values for uninitalised dates.
    
    Convert time64 equal to INT64_MAX to Python's None value.

diff --git a/bindings/python/time64.i b/bindings/python/time64.i
index 1fe6790..8273618 100644
--- a/bindings/python/time64.i
+++ b/bindings/python/time64.i
@@ -74,10 +74,14 @@
 // A typemap for converting time64 values returned from functions to
 // python dates. Note that we can't use Python DateTime's fromtimestamp function because it relies upon libc's localtime. Note also that while we create times with timegm we retrieve it with localtime
 %typemap(out) time64 {
-    PyDateTime_IMPORT;
-    struct tm t;
-    gnc_localtime_r(&$1, &t);
-    $result = PyDateTime_FromDateAndTime(t.tm_year + 1900, t.tm_mon + 1,
-                                         t.tm_mday, t.tm_hour, t.tm_min,
-                                         t.tm_sec, 0);
+    if ($1 == INT64_MAX) {
+        $result = Py_None;
+    } else {
+        PyDateTime_IMPORT;
+        struct tm t;
+        gnc_localtime_r(&$1, &t);
+        $result = PyDateTime_FromDateAndTime(t.tm_year + 1900, t.tm_mon + 1,
+                                             t.tm_mday, t.tm_hour, t.tm_min,
+                                             t.tm_sec, 0);
+    }
 }



Summary of changes:
 bindings/python/time64.i | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)



More information about the gnucash-changes mailing list