gnucash unstable: Multiple changes pushed

John Ralls jralls at code.gnucash.org
Sat Jan 20 18:04:17 EST 2018


Updated	 via  https://github.com/Gnucash/gnucash/commit/74ddb671 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/d86b6518 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/91f4b190 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/cc097a3f (commit)
	 via  https://github.com/Gnucash/gnucash/commit/ce90d540 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a47f2a04 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/ee8f9053 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/9fd53e68 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/152959ef (commit)
	 via  https://github.com/Gnucash/gnucash/commit/465c9e1f (commit)
	 via  https://github.com/Gnucash/gnucash/commit/2f2ad18d (commit)
	 via  https://github.com/Gnucash/gnucash/commit/fb2ed010 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/dda06952 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/46c9fcc8 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/fefea400 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/6d89cc70 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/4fd36b88 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/5c9432ad (commit)
	 via  https://github.com/Gnucash/gnucash/commit/c3c71e79 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/1b85f9ff (commit)
	 via  https://github.com/Gnucash/gnucash/commit/c1d61d50 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/9422d4ae (commit)
	 via  https://github.com/Gnucash/gnucash/commit/42b43250 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/5a2d4721 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/345ea0ab (commit)
	 via  https://github.com/Gnucash/gnucash/commit/e44df79b (commit)
	 via  https://github.com/Gnucash/gnucash/commit/e2c353fa (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a16532a9 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/629abc3c (commit)
	 via  https://github.com/Gnucash/gnucash/commit/d43df093 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/fada13e4 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/e3bd8f4d (commit)
	 via  https://github.com/Gnucash/gnucash/commit/896b9d97 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/03275a39 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/b23cb785 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/809936f0 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/46a2d18f (commit)
	 via  https://github.com/Gnucash/gnucash/commit/47544eaf (commit)
	 via  https://github.com/Gnucash/gnucash/commit/1adbe4d3 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/3adec363 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/0a96af20 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/0aa69a5f (commit)
	 via  https://github.com/Gnucash/gnucash/commit/1181f7fe (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a7eb1bcc (commit)
	 via  https://github.com/Gnucash/gnucash/commit/f2e1b9fb (commit)
	 via  https://github.com/Gnucash/gnucash/commit/811d4e57 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/db316c2d (commit)
	 via  https://github.com/Gnucash/gnucash/commit/98ef625a (commit)
	 via  https://github.com/Gnucash/gnucash/commit/1f61a6aa (commit)
	 via  https://github.com/Gnucash/gnucash/commit/7488565b (commit)
	 via  https://github.com/Gnucash/gnucash/commit/6e7ad4a2 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/1fb69fdf (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a4fe4979 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/c218c267 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/b1a73291 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/ecdea5dd (commit)
	 via  https://github.com/Gnucash/gnucash/commit/59a8a42f (commit)
	 via  https://github.com/Gnucash/gnucash/commit/78ea4545 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/b2eb687c (commit)
	 via  https://github.com/Gnucash/gnucash/commit/bca83e84 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/4dcf7a53 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/22422f77 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/e6f3abba (commit)
	 via  https://github.com/Gnucash/gnucash/commit/4d7e03b0 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/8fc31ce5 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a0d61b4f (commit)
	 via  https://github.com/Gnucash/gnucash/commit/c20c8ede (commit)
	 via  https://github.com/Gnucash/gnucash/commit/b53aa856 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/d41ad85f (commit)
	 via  https://github.com/Gnucash/gnucash/commit/7550ccf5 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/33a7bb73 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/33516510 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/e6ee0601 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/6dc982c2 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/1f050fd1 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/9a86dd22 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/598cb6d8 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/5dd12119 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/f77369bb (commit)
	 via  https://github.com/Gnucash/gnucash/commit/7390396a (commit)
	 via  https://github.com/Gnucash/gnucash/commit/30674863 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/588fcb6e (commit)
	 via  https://github.com/Gnucash/gnucash/commit/978ec61f (commit)
	 via  https://github.com/Gnucash/gnucash/commit/0bf0989a (commit)
	 via  https://github.com/Gnucash/gnucash/commit/dbd14737 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/b5aad8c7 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/61d4aaaf (commit)
	 via  https://github.com/Gnucash/gnucash/commit/2f89e459 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/95e31f98 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/7d510895 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/d36742d9 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/e9472149 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/168f6d67 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/ee56f5df (commit)
	from  https://github.com/Gnucash/gnucash/commit/47308f6b (commit)



commit 74ddb671e4c05340b9023d6c70a762ca6a9132d8
Merge: 47308f6 d86b651
Author: John Ralls <jralls at ceridwen.us>
Date:   Sat Jan 20 12:40:32 2018 -0800

    Merge Chris Lam's and Aaron Laws's branch 'time64-ftw' into unstable.

diff --cc bindings/python/CMakeLists.txt
index eda7931,9b17b2d..299887b
--- a/bindings/python/CMakeLists.txt
+++ b/bindings/python/CMakeLists.txt
@@@ -104,9 -104,9 +104,9 @@@ ENDIF(
  SET(python_bindings_DATA ${PYEXEC_FILES}
    gnucash_core.i
    sqlite3test.c
-   timespec.i)
+   time64.i)
  
 -SET_LOCAL_DIST(python_bindings_DIST_local CMakeLists.txt Makefile.am
 +SET_LOCAL_DIST(python_bindings_DIST_local CMakeLists.txt 
    ${python_bindings_DATA})
  
  SET(python_bindings_DIST ${python_bindings_DIST_local}

commit d86b65183d54d37c4ae4ee744c717be9b33a1549
Author: John Ralls <jralls at ceridwen.us>
Date:   Sat Jan 20 12:33:12 2018 -0800

    Remove Timespec from the guile base typemap.

diff --git a/common/base-typemaps.i b/common/base-typemaps.i
index 7a868a5..ddddb55 100644
--- a/common/base-typemaps.i
+++ b/common/base-typemaps.i
@@ -50,9 +50,6 @@ typedef char gchar;
 %typemap(in) gboolean "$1 = scm_is_true($input) ? TRUE : FALSE;"
 %typemap(out) gboolean "$result = $1 ? SCM_BOOL_T : SCM_BOOL_F;"
 
-%typemap(in) Timespec "$1 = gnc_timepair2timespec($input);"
-%typemap(out) Timespec "$result = gnc_timespec2timepair($1);"
-
 %typemap(in) GDate "$1 = gnc_time64_to_GDate($input);"
 
 %typemap(in) GncGUID "$1 = gnc_scm2guid($input);"

commit 91f4b190394df62a0485008ac7bce12b68d36eb3
Author: John Ralls <jralls at ceridwen.us>
Date:   Sat Jan 20 12:32:42 2018 -0800

    Convert python bindings from timespec to time64.

diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt
index 2038a35..9b17b2d 100644
--- a/bindings/python/CMakeLists.txt
+++ b/bindings/python/CMakeLists.txt
@@ -4,7 +4,7 @@ ADD_SUBDIRECTORY(tests)
 SET(PYEXEC_FILES  __init__.py function_class.py gnucash_business.py gnucash_core.py)
 
 IF (BUILDING_FROM_VCS)
-  SET(SWIG_FILES ${CMAKE_CURRENT_SOURCE_DIR}/gnucash_core.i ${CMAKE_CURRENT_SOURCE_DIR}/timespec.i)
+  SET(SWIG_FILES ${CMAKE_CURRENT_SOURCE_DIR}/gnucash_core.i ${CMAKE_CURRENT_SOURCE_DIR}/time64.i)
   SET(GNUCASH_CORE_C_INCLUDES
     ${CONFIG_H}
     ${CMAKE_SOURCE_DIR}/libgnucash/engine/qofsession.h
@@ -104,7 +104,7 @@ ENDIF()
 SET(python_bindings_DATA ${PYEXEC_FILES}
   gnucash_core.i
   sqlite3test.c
-  timespec.i)
+  time64.i)
 
 SET_LOCAL_DIST(python_bindings_DIST_local CMakeLists.txt Makefile.am
   ${python_bindings_DATA})
diff --git a/bindings/python/gnucash_core.i b/bindings/python/gnucash_core.i
index 83183e5..e2ba70e 100644
--- a/bindings/python/gnucash_core.i
+++ b/bindings/python/gnucash_core.i
@@ -85,7 +85,7 @@
 #include "Scrub3.h"
 %}
 
-%include <timespec.i>
+%include <time64.i>
 
 %include <base-typemaps.i>
 
diff --git a/bindings/python/tests/test_account.py b/bindings/python/tests/test_account.py
index 5ba972e..9478f37 100644
--- a/bindings/python/tests/test_account.py
+++ b/bindings/python/tests/test_account.py
@@ -34,8 +34,8 @@ class TestAccount( AccountSession ):
         tx = Transaction(self.book)
         tx.BeginEdit()
         tx.SetCurrency(self.currency)
-        tx.SetDateEnteredTS(datetime.now())
-        tx.SetDatePostedTS(datetime.now())
+        tx.SetDateEnteredSecs(datetime.now())
+        tx.SetDatePostedSecs(datetime.now())
 
         s1a = Split(self.book)
         s1a.SetParent(tx)
diff --git a/bindings/python/tests/test_business.py b/bindings/python/tests/test_business.py
index 6a2f1d6..fa96043 100644
--- a/bindings/python/tests/test_business.py
+++ b/bindings/python/tests/test_business.py
@@ -1,6 +1,6 @@
 from unittest import main
 
-from datetime import datetime
+from datetime import datetime, timedelta
 
 from gnucash import Account, \
     ACCT_TYPE_RECEIVABLE, ACCT_TYPE_INCOME, ACCT_TYPE_BANK, \
@@ -56,6 +56,8 @@ class TestBusiness( BusinessSession ):
         self.assertEqual( NAME, self.employee.GetUsername() )
 
     def test_post(self):
+        self.assertEqual(self.today - timedelta(0, 0, self.today.microsecond),
+                         self.invoice.GetDatePosted())
         self.assertTrue( self.invoice.IsPosted() )
 
     def test_owner(self):
diff --git a/bindings/python/time64.i b/bindings/python/time64.i
new file mode 100644
index 0000000..1fe6790
--- /dev/null
+++ b/bindings/python/time64.i
@@ -0,0 +1,83 @@
+/*
+ * time64.i -- SWIG interface file for type translation of time64 types
+ *
+ * Copyright (C) 2008 ParIT Worker Co-operative <paritinfo at parit.ca>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ *
+ * @author Mark Jenkins, ParIT Worker Co-operative <mark at parit.ca>
+ */
+
+/** @file
+    @brief SWIG interface file for type translation of time64 types
+    @author Mark Jenkins, ParIT Worker Co-operative <mark at parit.ca>
+    @author Jeff Green,   ParIT Worker Co-operative <jeff at parit.ca>
+    @ingroup python_bindings */
+
+// A typemap for converting python dates to time64 in functions that
+// require time64 as an argument
+%typemap(in) time64 {
+    PyDateTime_IMPORT;
+    struct tm time = {PyDateTime_DATE_GET_SECOND($input),
+                      PyDateTime_DATE_GET_MINUTE($input),
+                      PyDateTime_DATE_GET_HOUR($input),
+                      PyDateTime_GET_DAY($input),
+                      PyDateTime_GET_MONTH($input) - 1,
+                      PyDateTime_GET_YEAR($input) - 1900};
+    $1 = gnc_mktime(&time);
+}
+
+// A typemap for converting python dates to time64 *, for functions that
+// requires a time64 * as an argument. BIG ASSUMPTION, the function
+// receiving this pointer is going to make a copy of the data. After the
+// function call, the memory for the time64 used to perform this conversion
+// is going to be lost, so make damn sure that the recipient of this pointer
+// is NOT going dereference it sometime after this function call takes place.
+//
+// As far as I know, the xaccTransSetDate[Posted|Entered|Due]TS functions
+// from Transaction.h are the only functions with time64 * that we re
+// actually using. I have personally verified in the source that the pointer
+// being produced by this typemap is being dereferenced, and the data copied
+// in all three functions.
+// 
+// The memory for the time64 used for this conversion is allocated on the
+// stack. (SWIG will name the variables ts1, ts2, ts3...)
+//
+// Mark Jenkins <mark at parit.ca>
+%typemap(in) time64 * (time64 secs) {
+    PyDateTime_IMPORT;
+    struct tm time = {PyDateTime_DATE_GET_SECOND($input),
+                      PyDateTime_DATE_GET_MINUTE($input),
+                      PyDateTime_DATE_GET_HOUR($input),
+                      PyDateTime_GET_DAY($input),
+                      PyDateTime_GET_MONTH($input) - 1,
+                      PyDateTime_GET_YEAR($input) - 1900};
+    time64 secs = gnc_mktime(&time);
+    $1 = &secs;
+}
+
+// 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);
+}
diff --git a/bindings/python/timespec.i b/bindings/python/timespec.i
deleted file mode 100644
index 5612d52..0000000
--- a/bindings/python/timespec.i
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * timespec.i -- SWIG interface file for type translation of Timespec types
- *
- * Copyright (C) 2008 ParIT Worker Co-operative <paritinfo at parit.ca>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- *
- * @author Mark Jenkins, ParIT Worker Co-operative <mark at parit.ca>
- */
-
-/** @file
-    @brief SWIG interface file for type translation of Timespec types
-    @author Mark Jenkins, ParIT Worker Co-operative <mark at parit.ca>
-    @author Jeff Green,   ParIT Worker Co-operative <jeff at parit.ca>
-    @ingroup python_bindings */
-
-// A typemap for converting python dates to Timespec in functions that
-// require Timespec as an argument
-%typemap(in) Timespec {
-    PyDateTime_IMPORT;
-    $1 = gnc_dmy2timespec(PyDateTime_GET_DAY($input),
-                          PyDateTime_GET_MONTH($input),
-                          PyDateTime_GET_YEAR($input) );
-}
-
-// A typemap for converting python dates to Timespec *, for functions that
-// requires a Timespec * as an argument. BIG ASSUMPTION, the function
-// receiving this pointer is going to make a copy of the data. After the
-// function call, the memory for the Timespec used to perform this conversion
-// is going to be lost, so make damn sure that the recipient of this pointer
-// is NOT going dereference it sometime after this function call takes place.
-//
-// As far as I know, the xaccTransSetDate[Posted|Entered|Due]TS functions
-// from Transaction.h are the only functions with Timespec * that we re
-// actually using. I have personally verified in the source that the pointer
-// being produced by this typemap is being dereferenced, and the data copied
-// in all three functions.
-// 
-// The memory for the Timespec used for this conversion is allocated on the
-// stack. (SWIG will name the variables ts1, ts2, ts3...)
-//
-// Mark Jenkins <mark at parit.ca>
-%typemap(in) Timespec * (Timespec ts) {
-    PyDateTime_IMPORT;
-    ts = gnc_dmy2timespec(PyDateTime_GET_DAY($input),
-                          PyDateTime_GET_MONTH($input),
-                          PyDateTime_GET_YEAR($input) );
-    $1 = &ts;
-}
-
-// A typemap for converting Timespec values returned from functions to
-// python dates.
-%typemap(out) Timespec {
-    int year, month, day;
-    gnc_timespec2dmy($1, &day, &month, &year);
-    PyDateTime_IMPORT;
-    $result = PyDate_FromDate(year, month, day);
-}
diff --git a/libgnucash/engine/gncInvoice.c b/libgnucash/engine/gncInvoice.c
index 139f932..640eca1 100644
--- a/libgnucash/engine/gncInvoice.c
+++ b/libgnucash/engine/gncInvoice.c
@@ -29,6 +29,7 @@
 
 #include <config.h>
 
+#include <stdint.h>
 #include <glib.h>
 #include <glib/gi18n.h>
 #include <qofinstance-p.h>
@@ -136,6 +137,8 @@ G_DEFINE_TYPE(GncInvoice, gnc_invoice, QOF_TYPE_INSTANCE);
 static void
 gnc_invoice_init(GncInvoice* inv)
 {
+    inv->date_posted = INT64_MAX;
+    inv->date_opened = INT64_MAX;
 }
 
 static void
@@ -807,13 +810,13 @@ qofInvoiceGetBillTo (GncInvoice *invoice)
 
 time64 gncInvoiceGetDateOpened (const GncInvoice *invoice)
 {
-    if (!invoice) return 0;
+    if (!invoice) return INT64_MAX;
     return invoice->date_opened;
 }
 
 time64 gncInvoiceGetDatePosted (const GncInvoice *invoice)
 {
-    if (!invoice) return 0;
+    if (!invoice) return INT64_MAX;
     return invoice->date_posted;
 }
 
@@ -1718,7 +1721,7 @@ gncInvoiceUnpost (GncInvoice *invoice, gboolean reset_tax_tables)
     invoice->posted_acc = NULL;
     invoice->posted_txn = NULL;
     invoice->posted_lot = NULL;
-    invoice->date_posted = 0;
+    invoice->date_posted = INT64_MAX;
 
     /* if we've been asked to reset the tax tables, then do so */
     if (reset_tax_tables)
@@ -1855,7 +1858,7 @@ gncInvoiceApplyPayment (const GncInvoice *invoice, Transaction *txn,
 
 static gboolean gncInvoiceDateExists (time64 date)
 {
-    return date;
+    return date != INT64_MAX;
 }
 
 gboolean gncInvoiceIsPosted (const GncInvoice *invoice)

commit cc097a3f354985a30f1f89c46545fac972354723
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Jan 10 23:52:40 2018 +1100

    [mod|inc|dec]date64 API rename back to date
    
    This commit mass renames new t64 API back to the original names.

diff --git a/gnucash/import-export/qif-imp/qif-merge-groups.scm b/gnucash/import-export/qif-imp/qif-merge-groups.scm
index b2b83cc..b53c872 100644
--- a/gnucash/import-export/qif-imp/qif-merge-groups.scm
+++ b/gnucash/import-export/qif-imp/qif-merge-groups.scm
@@ -129,8 +129,8 @@
                   ;; The date should be close to the same.. +/- a week.
                   (let ((date (xaccTransGetDate xtn)))
                     (xaccQueryAddDateMatchTT query
-                                             #t (decdate64 date WeekDelta)
-                                             #t (incdate64 date WeekDelta)
+                                             #t (decdate date WeekDelta)
+                                             #t (incdate date WeekDelta)
                                              QOF-QUERY-AND))
 
                   ;; For each split in the new transaction, add a
diff --git a/gnucash/report/business-reports/aging.scm b/gnucash/report/business-reports/aging.scm
index 1ac7031..1746e92 100644
--- a/gnucash/report/business-reports/aging.scm
+++ b/gnucash/report/business-reports/aging.scm
@@ -487,14 +487,14 @@ copying this report to a spreadsheet for use in a mail merge.")
 
 (define (make-interval-list to-date)
   (let ((begindate to-date))
-    (set! begindate (decdate64 begindate ThirtyDayDelta))
-    (set! begindate (decdate64 begindate ThirtyDayDelta))
-    (set! begindate (decdate64 begindate ThirtyDayDelta))
+    (set! begindate (decdate begindate ThirtyDayDelta))
+    (set! begindate (decdate begindate ThirtyDayDelta))
+    (set! begindate (decdate begindate ThirtyDayDelta))
     (gnc:make-date-list begindate to-date ThirtyDayDelta)))
 
 ;; Have make-list create a stepped list, then add a date in the future for the "current" bucket
 (define (make-extended-interval-list to-date)
-    (define dayforcurrent (incdate64 to-date YearDelta)) ;; MAGIC CONSTANT
+    (define dayforcurrent (incdate to-date YearDelta)) ;; MAGIC CONSTANT
     (define oldintervalreversed (reverse (make-interval-list to-date)))		
   (reverse (cons dayforcurrent oldintervalreversed)))
 
diff --git a/gnucash/report/business-reports/job-report.scm b/gnucash/report/business-reports/job-report.scm
index 590875d..327e46b 100644
--- a/gnucash/report/business-reports/job-report.scm
+++ b/gnucash/report/business-reports/job-report.scm
@@ -118,9 +118,9 @@
 
 (define (make-interval-list to-date)
   (let ((begindate to-date))
-    (set! begindate (decdate64 begindate ThirtyDayDelta))
-    (set! begindate (decdate64 begindate ThirtyDayDelta))
-    (set! begindate (decdate64 begindate ThirtyDayDelta))
+    (set! begindate (decdate begindate ThirtyDayDelta))
+    (set! begindate (decdate begindate ThirtyDayDelta))
+    (set! begindate (decdate begindate ThirtyDayDelta))
     (gnc:make-date-list begindate to-date ThirtyDayDelta)))
 
 
diff --git a/gnucash/report/business-reports/owner-report.scm b/gnucash/report/business-reports/owner-report.scm
index 0516f69..7286ccd 100644
--- a/gnucash/report/business-reports/owner-report.scm
+++ b/gnucash/report/business-reports/owner-report.scm
@@ -204,14 +204,14 @@
 
 (define (make-interval-list to-date)
   (let ((begindate to-date))
-    (set! begindate (decdate64 begindate ThirtyDayDelta))
-    (set! begindate (decdate64 begindate ThirtyDayDelta))
-    (set! begindate (decdate64 begindate ThirtyDayDelta))
+    (set! begindate (decdate begindate ThirtyDayDelta))
+    (set! begindate (decdate begindate ThirtyDayDelta))
+    (set! begindate (decdate begindate ThirtyDayDelta))
     (gnc:make-date-list begindate to-date ThirtyDayDelta)))
 
 ;; Have make-list create a stepped list, then add a date in the future for the "current" bucket 
 (define (make-extended-interval-list to-date) 
-    (define dayforcurrent (incdate64 to-date YearDelta)) ;; MAGIC CONSTANT 
+    (define dayforcurrent (incdate to-date YearDelta)) ;; MAGIC CONSTANT 
     (define oldintervalreversed (reverse (make-interval-list to-date)))          
     (reverse (cons dayforcurrent oldintervalreversed))) 
 
diff --git a/gnucash/report/report-system/report-collectors.scm b/gnucash/report/report-system/report-collectors.scm
index 7fe4c91..4e587ad 100644
--- a/gnucash/report/report-system/report-collectors.scm
+++ b/gnucash/report/report-system/report-collectors.scm
@@ -155,7 +155,7 @@
     (list min-date max-date dates)))
 
 (define (category-report-dates-accumulate dates)
-  (let* ((min-date (decdate64 (car (list-min-max dates <)) DayDelta))
+  (let* ((min-date (decdate (car (list-min-max dates <)) DayDelta))
          (max-date (cdr (list-min-max dates <)))
          (datepairs (reverse! (cdr (fold (lambda (next acc)
                                            (let ((prev (car acc))
diff --git a/libgnucash/app-utils/app-utils.scm b/libgnucash/app-utils/app-utils.scm
index 256ca17..731cc09 100644
--- a/libgnucash/app-utils/app-utils.scm
+++ b/libgnucash/app-utils/app-utils.scm
@@ -213,8 +213,8 @@
 (export moddatek)
 (export decdate)
 (export incdate)
-(export decdate64)
-(export incdate64)
+(export decdate)
+(export incdate)
 (export gnc:time64-le-date)
 (export gnc:time64-ge-date)
 (export gnc:make-date-interval-list)
diff --git a/libgnucash/app-utils/date-utilities.scm b/libgnucash/app-utils/date-utilities.scm
index 62530de..3627d29 100644
--- a/libgnucash/app-utils/date-utilities.scm
+++ b/libgnucash/app-utils/date-utilities.scm
@@ -203,7 +203,7 @@
     (else #f)))
 
 ;; Modify a date
-(define (moddate64 op adate delta)
+(define (moddate op adate delta)
   (let ((newtm (gnc-localtime adate)))
     (begin
       (set-tm:sec newtm (op (tm:sec newtm) (tm:sec delta)))
@@ -216,8 +216,8 @@
       (gnc-mktime newtm))))
 
 ;; Add or subtract time from a date
-(define (decdate64 adate delta) (moddate64 - adate delta ))
-(define (incdate64 adate delta) (moddate64 + adate delta ))
+(define (decdate adate delta) (moddate - adate delta ))
+(define (incdate adate delta) (moddate + adate delta ))
 
 ;; date-granularity comparison functions.
 
@@ -235,9 +235,9 @@
 ;; want that you'll have to write another function.
 (define (gnc:make-date-interval-list current-date end-date increment)
   (if (< current-date end-date)
-      (let ((next-date (incdate64 current-date increment)))
+      (let ((next-date (incdate current-date increment)))
         (if (< next-date end-date)
-            (cons (list current-date (decdate64 next-date SecDelta) '())
+            (cons (list current-date (decdate next-date SecDelta) '())
                   (gnc:make-date-interval-list next-date end-date increment))
             (cons (list current-date end-date '())
                   '())))
@@ -251,7 +251,7 @@
 (define (gnc:make-date-list startdate enddate incr)
   (if (< startdate enddate)
       (cons startdate
-            (gnc:make-date-list (incdate64 startdate incr)
+            (gnc:make-date-list (incdate startdate incr)
                                 enddate incr))
       (list enddate)))
 
@@ -363,10 +363,10 @@
     (gnc-mktime bdt)))
 
 (define (gnc:time64-previous-day t64)
-  (decdate64 t64 DayDelta))
+  (decdate t64 DayDelta))
 
 (define (gnc:time64-next-day t64)
-  (incdate64 t64 DayDelta))
+  (incdate t64 DayDelta))
 
 
 (define (gnc:reldate-get-symbol x) (vector-ref x 0))

commit ce90d540b1c2d74b9a0624b80f9bab0eb5c9a98f
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue Jan 9 23:53:29 2018 +1100

    TP->T64: gnucash/report/utility-reports/hello-world.scm

diff --git a/gnucash/report/utility-reports/hello-world.scm b/gnucash/report/utility-reports/hello-world.scm
index 83d36e0..f7a7ed4 100644
--- a/gnucash/report/utility-reports/hello-world.scm
+++ b/gnucash/report/utility-reports/hello-world.scm
@@ -102,7 +102,7 @@
      (gnc:make-date-option
       (N_ "Hello, World!") (N_ "Just a Date Option")
       "d" (N_ "This is a date option.")
-      (lambda () (cons 'absolute (cons (current-time) 0)))
+      (lambda () (cons 'absolute (current-time)))
       #f 'absolute #f ))
     
     ;; This is another date option, but the user can also select
@@ -111,7 +111,7 @@
      (gnc:make-date-option
       (N_ "Hello, World!") (N_ "Time and Date Option")
       "e" (N_ "This is a date option with time.")
-      (lambda () (cons 'absolute (cons (current-time) 0)))
+      (lambda () (cons 'absolute (current-time)))
       #t 'absolute #f ))
     
     (add-option

commit a47f2a0465928be81dba602f8ad965f2c15cc907
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Jan 3 23:21:58 2018 +1100

    bugfix incorrect min-date handling

diff --git a/gnucash/report/report-system/report-collectors.scm b/gnucash/report/report-system/report-collectors.scm
index 25d97c5..7fe4c91 100644
--- a/gnucash/report/report-system/report-collectors.scm
+++ b/gnucash/report/report-system/report-collectors.scm
@@ -155,7 +155,7 @@
     (list min-date max-date dates)))
 
 (define (category-report-dates-accumulate dates)
-  (let* ((min-date 0) ; fixme. 
+  (let* ((min-date (decdate64 (car (list-min-max dates <)) DayDelta))
          (max-date (cdr (list-min-max dates <)))
          (datepairs (reverse! (cdr (fold (lambda (next acc)
                                            (let ((prev (car acc))

commit ee8f9053e85169d891d0577ea4cce811f1dc6239
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Jan 3 19:42:27 2018 +1100

    REMOVE-TIMEPAIR: libgnucash/app-utils/app-utils.scm & date-utilities.scm
    
    This commit removes timepair API functions defined in date-utilities.scm

diff --git a/libgnucash/app-utils/app-utils.scm b/libgnucash/app-utils/app-utils.scm
index 0ada8b5..256ca17 100644
--- a/libgnucash/app-utils/app-utils.scm
+++ b/libgnucash/app-utils/app-utils.scm
@@ -180,11 +180,6 @@
 ;; date-utilities.scm
 
 (export gnc:reldate-list)
-(export gnc:timepair->secs)
-(export gnc:secs->timepair)
-(export gnc:timepair->date)
-(export gnc:date->timepair)
-(export gnc:timepair?)
 (export gnc:date-get-year)
 (export gnc:date-get-quarter)
 (export gnc:date-get-month-day)
@@ -192,13 +187,6 @@
 (export gnc:date-get-week-day)
 (export gnc:date-get-week)
 (export gnc:date-get-year-day)
-(export gnc:timepair-get-year)
-(export gnc:timepair-get-quarter)
-(export gnc:timepair-get-month-day)
-(export gnc:timepair-get-month)
-(export gnc:timepair-get-week-day)
-(export gnc:timepair-get-week)
-(export gnc:timepair-get-year-day)
 (export gnc:time64-get-year)
 (export gnc:time64-get-quarter)
 (export gnc:time64-get-month-day)
@@ -227,18 +215,6 @@
 (export incdate)
 (export decdate64)
 (export incdate64)
-(export gnc:timepair-later)
-(export gnc:timepair-lt)
-(export gnc:timepair-earlier)
-(export gnc:timepair-gt)
-(export gnc:timepair-le)
-(export gnc:timepair-ge)
-(export gnc:timepair-eq)
-(export gnc:timepair-earlier-date)
-(export gnc:timepair-later-date)
-(export gnc:timepair-le-date)
-(export gnc:timepair-ge-date)
-(export gnc:timepair-eq-date)
 (export gnc:time64-le-date)
 (export gnc:time64-ge-date)
 (export gnc:make-date-interval-list)
@@ -255,12 +231,6 @@
 (export ThirtyDayDelta)
 (export NinetyDayDelta)
 (export gnc:deltasym-to-delta)
-(export gnc:timepair-delta)
-(export gnc:time-elapsed)
-(export gnc:timepair-start-day-time)
-(export gnc:timepair-end-day-time)
-(export gnc:timepair-previous-day)
-(export gnc:timepair-next-day)
 (export gnc:time64-start-day-time)
 (export gnc:time64-end-day-time)
 (export gnc:time64-previous-day)
diff --git a/libgnucash/app-utils/date-utilities.scm b/libgnucash/app-utils/date-utilities.scm
index 5df5c9a..62530de 100644
--- a/libgnucash/app-utils/date-utilities.scm
+++ b/libgnucash/app-utils/date-utilities.scm
@@ -27,29 +27,6 @@
 
 (define gnc:reldate-list '())
 
-(define (gnc:timepair->secs tp)
-  (gnc:warn "deprecated timepair->secs, use time64 directly")
-  (inexact->exact 
-   (+ (car tp)
-      (/ (cdr tp) 1000000000))))
-
-(define (gnc:secs->timepair secs)
-  (gnc:warn "deprecated secs->timepair, use time64 direclty")
-  (cons secs 0))
-
-(define (gnc:timepair->date tp)
-  (gnc:warn "deprecated timepair->date, use gnc-localtime")
-  (gnc-localtime (gnc:timepair->secs tp)))
-
-(define (gnc:date->timepair date)
-  (gnc:warn "deprecated timepair->date, use gnc-mktime")
-  (gnc:secs->timepair (gnc-mktime date)))
-
-(define (gnc:timepair? date)
-  (gnc:warn "deprecated timepair?")
-  (and (number? (car date))
-       (number? (cdr date))))
-
 ;; get stuff from localtime date vector
 (define (gnc:date-get-year datevec)
   (+ 1900 (tm:year datevec)))
@@ -70,34 +47,6 @@
 (define (gnc:date-get-year-day datevec)
   (+ (tm:yday datevec) 1))
 
-(define (gnc:timepair-get-year tp)
-  (gnc:warn "deprecated timepair-get-year")
-  (gnc:date-get-year (gnc:timepair->date tp)))
-
-(define (gnc:timepair-get-quarter tp)
-  (gnc:warn "deprecated timepair-get-quarter")
-  (gnc:date-get-quarter (gnc:timepair->date tp)))
-
-(define (gnc:timepair-get-month-day tp)
-  (gnc:warn "deprecated timepair-get-month-day")
-  (gnc:date-get-month-day (gnc:timepair->date tp)))
-
-(define (gnc:timepair-get-month tp)
-  (gnc:warn "deprecated timepair-get-month")
-  (gnc:date-get-month (gnc:timepair->date tp)))
-
-(define (gnc:timepair-get-week-day tp)
-  (gnc:warn "deprecated timepair-get-week-day")
-  (gnc:date-get-week-day (gnc:timepair->date tp)))
-
-(define (gnc:timepair-get-week tp)
-  (gnc:warn "deprecated timepair-get-week")
-  (gnc:date-get-week (gnc:timepair->date tp)))
-
-(define (gnc:timepair-get-year-day tp)
-  (gnc:warn "deprecated timepair-get-year-day")
-  (gnc:date-get-year-day (gnc:timepair->date tp)))
-
 (define (gnc:time64-get-year t64)
   (gnc:date-get-year (gnc-localtime t64)))
 
@@ -254,19 +203,6 @@
     (else #f)))
 
 ;; Modify a date
-(define (moddate op adate delta)
-  (gnc:warn "deprecated moddate. use moddate64 instead.")
-  (let ((newtm (gnc:timepair->date adate)))
-    (begin
-      (set-tm:sec newtm (op (tm:sec newtm) (tm:sec delta)))
-      (set-tm:min newtm (op (tm:min newtm) (tm:min delta)))
-      (set-tm:hour newtm (op (tm:hour newtm) (tm:hour delta)))
-      (set-tm:mday newtm (op (tm:mday newtm) (tm:mday delta)))
-      (set-tm:mon newtm (op (tm:mon newtm) (tm:mon delta)))
-      (set-tm:year newtm (op (tm:year newtm) (tm:year delta)))
-      (set-tm:isdst newtm 0)
-      (gnc:date->timepair newtm))))
-
 (define (moddate64 op adate delta)
   (let ((newtm (gnc-localtime adate)))
     (begin
@@ -280,71 +216,11 @@
       (gnc-mktime newtm))))
 
 ;; Add or subtract time from a date
-(define (decdate adate delta)(moddate - adate delta ))
-(define (incdate adate delta)(moddate + adate delta ))
-
 (define (decdate64 adate delta) (moddate64 - adate delta ))
 (define (incdate64 adate delta) (moddate64 + adate delta ))
 
-;; Time comparison, true if t2 is later than t1
-;; FIXME: RENAME THIS FUNCTION!!!!
-;; NOTE ALL THESE FUNCTIONS WILL BECOME OBSOLETE SOON
-
-(define (gnc:timepair-later t1 t2)
-  (gnc:warn "deprecated timepair-later")
-  (cond ((< (car t1) (car t2)) #t)
-        ((= (car t1) (car t2)) (< (cdr t2) (cdr t2)))
-        (else #f)))
-
-(define (gnc:timepair-lt t1 t2)
-  (gnc:warn "deprecated timepair-lt")
-  (gnc:timepair-later t1 t2))
-
-(define (gnc:timepair-earlier t1 t2)
-  (gnc:warn "deprecated timepair-earlier")
-  (gnc:timepair-later t2 t1))
-
-(define (gnc:timepair-gt t1 t2)
-  (gnc:warn "deprecated timepair-gt")
-  (gnc:timepair-earlier t1 t2))
-
-;; t1 <= t2
-(define (gnc:timepair-le t1 t2)
-  (gnc:warn "deprecated timepair-le")
-  (cond ((< (car t1) (car t2)) #t)
-        ((= (car t1) (car t2)) (<= (cdr t2) (cdr t2)))
-        (else #f)))
-
-(define (gnc:timepair-ge t1 t2)
-  (gnc:warn "deprecated timepair-ge")
-  (gnc:timepair-le t2 t1))
-
-(define (gnc:timepair-eq t1 t2)
-  (gnc:warn "deprecated timepair-eq")
-  (and (= (car t1) (car t2)) (= (cdr t1) (cdr t2))))
-
 ;; date-granularity comparison functions.
 
-(define (gnc:timepair-earlier-date t1 t2)
-  (gnc:timepair-earlier (timespecCanonicalDayTime t1)
-			(timespecCanonicalDayTime t2)))
-
-(define (gnc:timepair-later-date t1 t2)
-  (gnc:timepair-earlier-date t2 t1))
-
-(define (gnc:timepair-le-date t1 t2)
-  (gnc:warn "deprecated gnc:timepair-le-date. use gnc:time64-le-date")
-  (gnc:timepair-le (timespecCanonicalDayTime t1)
-		   (timespecCanonicalDayTime t2)))
-
-(define (gnc:timepair-ge-date t1 t2)
-  (gnc:warn "deprecated timepair-ge-date")
-  (gnc:timepair-le t2 t1))
-
-(define (gnc:timepair-eq-date t1 t2)
-  (gnc:timepair-eq (timespecCanonicalDayTime t1)
-		   (timespecCanonicalDayTime t2)))
-
 (define (gnc:time64-le-date t1 t2)
   (<= (time64CanonicalDayTime t1)
       (time64CanonicalDayTime t2)))
@@ -357,16 +233,6 @@
 ;; Note that the last interval will be shorter than <incr> if
 ;; (<curd>-<endd>) is not an integer multiple of <incr>. If you don't
 ;; want that you'll have to write another function.
-(define (gnc:make-datepair-interval-list curd endd incr)
-  (gnc:warn "deprecated gnc:make-date-interval-list")
-  (cond ((gnc:timepair-later curd endd)
-	 (let ((nextd (incdate curd incr)))
-	   (cond ((gnc:timepair-later nextd endd)
-		  (cons (list curd (decdate nextd SecDelta) '())
-			(gnc:make-date-interval-list nextd endd incr)))
-		  (else (cons (list curd endd '()) '())))))
-	(else '())))
-
 (define (gnc:make-date-interval-list current-date end-date increment)
   (if (< current-date end-date)
       (let ((next-date (incdate64 current-date increment)))
@@ -382,14 +248,6 @@
 ;; not an integer multiple of 'incr', 'enddate' will be added as the
 ;; last element of the list, thus making the last interval smaller
 ;; than 'incr'.
-(define (gnc:make-datepair-list startdate enddate incr)
-  (gnc:warn "deprecated gnc:make-date-list")
-  (cond ((gnc:timepair-later startdate enddate)
-	 (cons startdate 
-	       (gnc:make-date-list (incdate startdate incr) 
-				   enddate incr)))
-	(else (list enddate))))
-
 (define (gnc:make-date-list startdate enddate incr)
   (if (< startdate enddate)
       (cons startdate
@@ -485,53 +343,9 @@
 	(cdr retval)
 	#f)))
 
-;; Find difference in seconds time 1 and time2
-(define (gnc:timepair-delta t1 t2)
-  (gnc:warn "(gnc:timepair-delta) obsolete. use (-) directly")
-  (- (gnc:timepair->secs t2) (gnc:timepair->secs t1)))
-
-;; find float difference between times 
-(define (gnc:time-elapsed t1 t2)
-  (+ (- (car t2)
-        (car t1))
-     (/ (- (cdr t2)
-           (cdr t1)) 1000000.0)))
-
-;; timepair manipulation functions
-;; hack alert  - these should probably be put somewhere else
-;; and be implemented PROPERLY rather than hackily
-;;; Added from transaction-report.scm
-
-;; given a timepair contains any time on a certain day (local time)
+;; given a time64 time on a certain day (local time)
 ;; converts it to be midday that day.
 
-(define (gnc:timepair-start-day-time tp)
-  (gnc:warn "(gnc:timepair-start-day-time) obsolete")
-  (let ((bdt (gnc:timepair->date tp)))
-    (set-tm:sec bdt 0)
-    (set-tm:min bdt 0)
-    (set-tm:hour bdt 0)
-    (set-tm:isdst bdt -1)
-    (gnc:date->timepair bdt)))
-
-(define (gnc:timepair-end-day-time tp)
-  (gnc:warn "(gnc:timepair-end-day-time) obsolete")
-  (let ((bdt (gnc:timepair->date tp)))
-    (set-tm:sec bdt 59)
-    (set-tm:min bdt 59)
-    (set-tm:hour bdt 23)
-    (set-tm:isdst bdt -1)
-    (gnc:date->timepair bdt)))
-
-(define (gnc:timepair-previous-day tp)
-  (gnc:warn "gnc:timepair-previous-day obsolete")
-  (decdate tp DayDelta))
-
-(define (gnc:timepair-next-day tp)
-  (gnc:warn "gnc:timepair-next-day obsolete")
-  (incdate tp DayDelta))
-
-;; new time64 helper functions
 (define (gnc:time64-start-day-time t64)
   (let ((bdt (gnc-localtime t64)))
     (set-tm:sec bdt 0)
@@ -866,7 +680,7 @@
       (if (> month-days (tm:mday now))
 	  (set-tm:mday now month-days))
       (set-tm:isdst now -1)
-      (gnc:date->timepair now))))
+      (gnc-mktime now))))
 
 (define (gnc:get-one-year-ago)
   (let ((now (gnc-localtime (current-time))))

commit 9fd53e6869c343a86ce72912327576ac8de2cb76
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Jan 3 05:54:45 2018 +1100

    TP->T64: gnucash/report/standard-reports/advanced-portfolio.scm
    
    Missed gnc-pricedb-lookup-in-time-any-currency

diff --git a/gnucash/report/standard-reports/advanced-portfolio.scm b/gnucash/report/standard-reports/advanced-portfolio.scm
index bf7cefb..a31af27 100644
--- a/gnucash/report/standard-reports/advanced-portfolio.scm
+++ b/gnucash/report/standard-reports/advanced-portfolio.scm
@@ -1039,7 +1039,7 @@
                                 domestic)))
                   ((pricedb-nearest)
                    (lambda (foreign domestic date)
-                    (find-price (gnc-pricedb-lookup-nearest-in-time-any-currency
+                    (find-price (gnc-pricedb-lookup-nearest-in-time-any-currency-t64
 		     pricedb foreign (time64CanonicalDayTime date)) domestic)))))
 	       (headercols (list (_ "Account")))
 	       (totalscols (list (gnc:make-html-table-cell/markup "total-label-cell" (_ "Total"))))

commit 152959efe468fbd23aaa41faeb427e61bb6342e1
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Jan 3 05:43:24 2018 +1100

    TP->T64: gnucash/report/locale-specific/us/taxtxf.scm
    
    Missed gnc-pricedb-lookup-nearest-in-time64

diff --git a/gnucash/report/locale-specific/us/taxtxf.scm b/gnucash/report/locale-specific/us/taxtxf.scm
index e5aeb30..de8ddca 100644
--- a/gnucash/report/locale-specific/us/taxtxf.scm
+++ b/gnucash/report/locale-specific/us/taxtxf.scm
@@ -719,7 +719,7 @@
                               (begin ;; do so
                                 (set! missing-pricedb-entry? #f)
                                 (set! pricedb-lookup-price
-                                        (let ((price (gnc-pricedb-lookup-nearest-in-time
+                                        (let ((price (gnc-pricedb-lookup-nearest-in-time64
                                           pricedb
                                           account-commodity
                                           USD-currency
@@ -732,7 +732,7 @@
                                         (gnc-price-get-value
                                                           pricedb-lookup-price))
                                 (set! pricedb-lookup-price-time
-                                        (gnc-price-get-time
+                                        (gnc-price-get-time64
                                                           pricedb-lookup-price))
                                 (gnc-pricedb-convert-balance-nearest-price
                                         pricedb

commit 465c9e1f21823980717d6f66e07af93e2c2cdd2c
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Jan 3 05:42:29 2018 +1100

    ADD-TIME64-API: libgnucash/engine/gnc-pricedb.[ch]
    
    gnc_pricedb_lookup_nearest_in_time64
    gnc_pricedb_lookup_nearest_in_time_any_currency_t64

diff --git a/libgnucash/engine/gnc-pricedb.c b/libgnucash/engine/gnc-pricedb.c
index 0d4fb50..ab16aa0 100644
--- a/libgnucash/engine/gnc-pricedb.c
+++ b/libgnucash/engine/gnc-pricedb.c
@@ -2069,6 +2069,18 @@ gnc_pricedb_lookup_nearest_in_time_any_currency(GNCPriceDB *db,
 }
 
 PriceList *
+gnc_pricedb_lookup_nearest_in_time_any_currency_t64(GNCPriceDB *db,
+                                                    const gnc_commodity *commodity,
+                                                    time64 t64)
+{
+    Timespec t;
+    t.tv_sec = t64;
+    t.tv_nsec = 0;
+
+    return gnc_pricedb_lookup_nearest_in_time_any_currency(db, commodity, t);
+}
+
+PriceList *
 gnc_pricedb_lookup_latest_before_any_currency(GNCPriceDB *db,
                                               const gnc_commodity *commodity,
                                               Timespec t)
@@ -2443,6 +2455,18 @@ gnc_pricedb_lookup_nearest_in_time(GNCPriceDB *db,
 }
 
 GNCPrice *
+gnc_pricedb_lookup_nearest_in_time64(GNCPriceDB *db,
+                                     const gnc_commodity *c,
+                                     const gnc_commodity *currency,
+                                     time64 t64)
+{
+    Timespec t;
+    t.tv_sec = t64;
+    t.tv_nsec = 0;
+    return lookup_nearest_in_time(db, c, currency, t, FALSE);
+}
+
+GNCPrice *
 gnc_pricedb_lookup_latest_before (GNCPriceDB *db,
                                   gnc_commodity *c,
                                   gnc_commodity *currency,
diff --git a/libgnucash/engine/gnc-pricedb.h b/libgnucash/engine/gnc-pricedb.h
index f4fe839..a2dddaf 100644
--- a/libgnucash/engine/gnc-pricedb.h
+++ b/libgnucash/engine/gnc-pricedb.h
@@ -517,6 +517,11 @@ GNCPrice   * gnc_pricedb_lookup_nearest_in_time(GNCPriceDB *db,
         const gnc_commodity *currency,
         Timespec t);
 
+GNCPrice   * gnc_pricedb_lookup_nearest_in_time64(GNCPriceDB *db,
+        const gnc_commodity *c,
+        const gnc_commodity *currency,
+        time64 t);
+
 /** @brief Return the price nearest in time to that given between the given
  * commodity and every other.
  *
@@ -532,6 +537,9 @@ GNCPrice   * gnc_pricedb_lookup_nearest_in_time(GNCPriceDB *db,
 PriceList * gnc_pricedb_lookup_nearest_in_time_any_currency(GNCPriceDB *db,
         const gnc_commodity *c,
         Timespec t);
+PriceList * gnc_pricedb_lookup_nearest_in_time_any_currency_t64(GNCPriceDB *db,
+        const gnc_commodity *c,
+        time64 t64);
 
 /** @brief Return the latest price between the given commodities before the
  * given time.

commit 2f2ad18dfec2db698e06b84a3f3047d4cb9b6874
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Jan 1 23:09:51 2018 +1100

    TP->T64: gnucash/import-export/qif-imp/qif-merge-groups.scm

diff --git a/gnucash/import-export/qif-imp/qif-merge-groups.scm b/gnucash/import-export/qif-imp/qif-merge-groups.scm
index 40fa301..b2b83cc 100644
--- a/gnucash/import-export/qif-imp/qif-merge-groups.scm
+++ b/gnucash/import-export/qif-imp/qif-merge-groups.scm
@@ -127,10 +127,10 @@
                                             QOF-GUID-MATCH-ANY QOF-QUERY-AND)
 
                   ;; The date should be close to the same.. +/- a week.
-                  (let ((date (gnc-transaction-get-date-posted xtn)))
-                    (xaccQueryAddDateMatchTS query #t
-                                             (decdate date WeekDelta) #t
-                                             (incdate date WeekDelta)
+                  (let ((date (xaccTransGetDate xtn)))
+                    (xaccQueryAddDateMatchTT query
+                                             #t (decdate64 date WeekDelta)
+                                             #t (incdate64 date WeekDelta)
                                              QOF-QUERY-AND))
 
                   ;; For each split in the new transaction, add a

commit fb2ed010e7939fa9a2ba78b35908e2f941ed1179
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Dec 30 21:59:33 2017 +1100

    TP->T64: libgnucash/scm/price-quotes.scm

diff --git a/libgnucash/scm/price-quotes.scm b/libgnucash/scm/price-quotes.scm
index c67876b..f644f54 100644
--- a/libgnucash/scm/price-quotes.scm
+++ b/libgnucash/scm/price-quotes.scm
@@ -353,10 +353,9 @@
                        fq-results)
              (reverse result-list)))))
 
-  (define (timestr->time-pair timestr time-zone)
+  (define (timestr->time64 timestr time-zone)
     ;; time-zone is ignored currently
-    (cons (gnc-parse-time-to-time64 timestr "%Y-%m-%d %H:%M:%S")
-          0))
+    (gnc-parse-time-to-time64 timestr "%Y-%m-%d %H:%M:%S"))
 
   (define (commodity-tz-quote-triple->price book c-tz-quote-triple)
     ;; return a string like "NASDAQ:CSCO" on error, or a price on
@@ -413,16 +412,16 @@
                                                    GNC-RND-ROUND))))
 
       (if gnc-time
-          (set! gnc-time (timestr->time-pair gnc-time time-zone))
+          (set! gnc-time (timestr->time64 gnc-time time-zone))
           (set! gnc-time (gnc:get-today)))
 
       (if (not (and commodity currency gnc-time price price-type))
           (string-append
            currency-str ":" (gnc-commodity-get-mnemonic commodity))
           (begin
-            (set! saved-price (gnc-pricedb-lookup-day pricedb
-                                                      commodity currency
-                                                      gnc-time))
+            (set! saved-price (gnc-pricedb-lookup-day64 pricedb
+							commodity currency
+							gnc-time))
             (if (not (null? saved-price))
                 (begin
                   (if (gnc-commodity-equiv (gnc-price-get-currency saved-price)
@@ -431,7 +430,7 @@
                   (if (>= (gnc-price-get-source saved-price) PRICE-SOURCE-FQ)
                       (begin
                         (gnc-price-begin-edit saved-price)
-                        (gnc-price-set-time saved-price gnc-time)
+                        (gnc-price-set-time64 saved-price gnc-time)
                         (gnc-price-set-source saved-price PRICE-SOURCE-FQ)
                         (gnc-price-set-typestr saved-price price-type)
                         (gnc-price-set-value saved-price price)
@@ -446,7 +445,7 @@
                         (gnc-price-begin-edit gnc-price)
                         (gnc-price-set-commodity gnc-price commodity)
                         (gnc-price-set-currency gnc-price currency)
-                        (gnc-price-set-time gnc-price gnc-time)
+                        (gnc-price-set-time64 gnc-price gnc-time)
                         (gnc-price-set-source gnc-price PRICE-SOURCE-FQ)
                         (gnc-price-set-typestr gnc-price price-type)
                         (gnc-price-set-value gnc-price price)

commit dda06952851c5908d15fbaae7332170571561080
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Dec 30 21:59:18 2017 +1100

    ADD-TIME64-API: libgnucash/engine/gnc-pricedb.[ch]

diff --git a/libgnucash/engine/gnc-pricedb.c b/libgnucash/engine/gnc-pricedb.c
index d550f24..0d4fb50 100644
--- a/libgnucash/engine/gnc-pricedb.c
+++ b/libgnucash/engine/gnc-pricedb.c
@@ -518,6 +518,27 @@ gnc_price_set_time(GNCPrice *p, Timespec t)
 }
 
 void
+gnc_price_set_time64(GNCPrice *p, time64 t64)
+{
+    if (!p) return;
+    if (p->tmspec.tv_sec != t64)  // do we need to check nsec as well?
+    {
+        /* Changing the datestamp requires the hash table
+         * position to be modified. The easiest way of doing
+         * this is to remove and reinsert. */
+        gnc_price_ref (p);
+        remove_price (p->db, p, FALSE);
+        gnc_price_begin_edit (p);
+        p->tmspec.tv_sec = t64;
+	p->tmspec.tv_nsec = 0;
+        gnc_price_set_dirty(p);
+        gnc_price_commit_edit (p);
+        add_price (p->db, p);
+        gnc_price_unref (p);
+    }
+}
+
+void
 gnc_price_set_source(GNCPrice *p, PriceSource s)
 {
     if (!p) return;
@@ -2259,6 +2280,18 @@ gnc_pricedb_lookup_day(GNCPriceDB *db,
 }
 
 GNCPrice *
+gnc_pricedb_lookup_day_t64(GNCPriceDB *db,
+                       const gnc_commodity *c,
+                       const gnc_commodity *currency,
+                       time64 t64)
+{
+    Timespec t;
+    t.tv_sec = t64;
+    t.tv_nsec = 0;
+    return lookup_nearest_in_time(db, c, currency, t, TRUE);
+}
+
+GNCPrice *
 gnc_pricedb_lookup_at_time(GNCPriceDB *db,
                            const gnc_commodity *c,
                            const gnc_commodity *currency,
diff --git a/libgnucash/engine/gnc-pricedb.h b/libgnucash/engine/gnc-pricedb.h
index f2117f8..f4fe839 100644
--- a/libgnucash/engine/gnc-pricedb.h
+++ b/libgnucash/engine/gnc-pricedb.h
@@ -239,6 +239,7 @@ void gnc_price_commit_edit (GNCPrice *p);
 void gnc_price_set_commodity(GNCPrice *p, gnc_commodity *c);
 void gnc_price_set_currency(GNCPrice *p, gnc_commodity *c);
 void gnc_price_set_time(GNCPrice *p, Timespec t);
+void gnc_price_set_time64(GNCPrice *p, time64 t64);
 void gnc_price_set_source(GNCPrice *p, PriceSource source);
 void gnc_price_set_source_string(GNCPrice *p, const char* s);
 void gnc_price_set_typestr(GNCPrice *p, const char* type);
@@ -495,6 +496,10 @@ GNCPrice * gnc_pricedb_lookup_day(GNCPriceDB *db,
                                   const gnc_commodity *currency,
                                   Timespec t);
 
+GNCPrice * gnc_pricedb_lookup_day_t64(GNCPriceDB *db,
+                                  const gnc_commodity *commodity,
+                                  const gnc_commodity *currency,
+                                  time64 t64);
 
 /** @brief Return the price between the two commoditiesz nearest to the given
  * time.

commit 46c9fcc8f8391d07050265d5c53590214579f8ae
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Thu Dec 28 19:07:10 2017 +1100

    TP->T64: libgnucash/engine/test/test-split.scm

diff --git a/libgnucash/engine/test/test-split.scm b/libgnucash/engine/test/test-split.scm
index 7cd8183..96713c4 100644
--- a/libgnucash/engine/test/test-split.scm
+++ b/libgnucash/engine/test/test-split.scm
@@ -12,7 +12,7 @@
 
 (define (test-split-in-list?)
   (let* ((env (create-test-env))
-	 (today (gnc:date->timepair (gnc-localtime (current-time))))
+	 (today (current-time))
 	 (account-alist (env-create-test-accounts env))
 	 (bank-account (cdr (assoc "Bank" account-alist)))
 	 (expense-account (cdr (assoc "Expenses" account-alist)))

commit fefea400ce37e1b3133a6eb6f8c2b989f8e19dc5
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Dec 24 13:16:41 2017 +0800

    TP->T64: libgnucash/engine/engine-interface.scm

diff --git a/libgnucash/engine/engine-interface.scm b/libgnucash/engine/engine-interface.scm
index e811320..a1217ef 100644
--- a/libgnucash/engine/engine-interface.scm
+++ b/libgnucash/engine/engine-interface.scm
@@ -101,7 +101,7 @@
    (xaccSplitGetMemo split)
    (xaccSplitGetAction split)
    (xaccSplitGetReconcile split)
-   (gnc-split-get-date-reconciled split)
+   (xaccSplitGetDateReconciled split)
    (xaccSplitGetAmount split)
    (xaccSplitGetValue split)))
 
@@ -226,9 +226,9 @@
   (gnc:make-transaction-scm
    (gncTransGetGUID trans)
    (xaccTransGetCurrency trans)
-   (gnc-transaction-get-date-entered trans)
+   (xaccTransGetDateEntered trans)
    (if use-cut-semantics?
-       (gnc-transaction-get-date-posted trans)
+       (xaccTransGetDate trans)
        #f)
    (if use-cut-semantics?
        (xaccTransGetNum trans)
@@ -259,8 +259,7 @@
           (if description (xaccTransSetDescription trans description))
           (if num         (xaccTransSetNum trans num))
           (if notes       (xaccTransSetNotes trans notes))
-          (if date-posted (gnc-transaction-set-date
-                           trans date-posted)))
+          (if date-posted (xaccTransSetDatePostedSecs trans date-posted)))
 
         ;; strip off the old splits
         (for-each (lambda (split)

commit 6d89cc70becc238c1dce00b154bede99c367092c
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Dec 24 06:47:31 2017 +0800

    TP->T64: gnucash/report/utility-reports/hello-world.scm

diff --git a/gnucash/report/utility-reports/hello-world.scm b/gnucash/report/utility-reports/hello-world.scm
index 8ee7b30..83d36e0 100644
--- a/gnucash/report/utility-reports/hello-world.scm
+++ b/gnucash/report/utility-reports/hello-world.scm
@@ -267,13 +267,13 @@ option like this.")
 
     ;; these are samples of different date options. for a simple
     ;; date with day, month, and year but no time you should use
-    ;; gnc-print-date
+    ;; qof-print-date
     (let ((time-string (strftime "%X" (gnc-localtime (current-time))))
-          (date-string (strftime "%x" (gnc-localtime (car date-val))))
-          (date-string2 (strftime "%x %X" (gnc-localtime (car date2-val))))
-          (rel-date-string (strftime "%x" (gnc-localtime (car rel-date-val))))
+          (date-string (strftime "%x" (gnc-localtime date-val)))
+          (date-string2 (strftime "%x %X" (gnc-localtime date2-val)))
+          (rel-date-string (strftime "%x" (gnc-localtime rel-date-val)))
           (combo-date-string
-           (strftime "%x" (gnc-localtime (car combo-date-val)))))
+           (strftime "%x" (gnc-localtime combo-date-val))))
 
       ;; Here's where we fill the report document with content.  We
       ;; do this by adding 'html objects' such as text, tables, and

commit 4fd36b889f0034fa32ca54d1b9151c33d58c9808
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Dec 24 06:47:07 2017 +0800

    TP->T64: gnucash/report/stylesheets/stylesheet-head-or-tail.scm

diff --git a/gnucash/report/stylesheets/stylesheet-head-or-tail.scm b/gnucash/report/stylesheets/stylesheet-head-or-tail.scm
index e31cb46..d3cc1ae 100644
--- a/gnucash/report/stylesheets/stylesheet-head-or-tail.scm
+++ b/gnucash/report/stylesheets/stylesheet-head-or-tail.scm
@@ -534,7 +534,7 @@
               (gnc:make-html-text
                 (gnc:html-markup-i
                   (_ "Report Creation Date: ")
-                  (gnc-print-date (gnc:get-today))
+                  (qof-print-date (gnc:get-today))
                   " "
                   (strftime "%X %Z" (localtime (current-time)))
                 )
@@ -543,7 +543,7 @@
               (gnc:make-html-text
                 (gnc:html-markup-i
                   (_ "Report Creation Date: ")
-                  (gnc-print-date (gnc:get-today))
+                  (qof-print-date (gnc:get-today))
                 )
                 (gnc:html-markup-br)
               )
@@ -659,7 +659,7 @@
             (gnc:make-html-text
               (gnc:html-markup-i
                 (_ "Report Creation Date: ")
-                (gnc-print-date (gnc:get-today))
+                (qof-print-date (gnc:get-today))
                 " "
                 (strftime "%X %Z" (localtime (current-time)))
               )
@@ -668,7 +668,7 @@
             (gnc:make-html-text
               (gnc:html-markup-i
                 (_ "Report Creation Date: ")
-                (gnc-print-date (gnc:get-today))
+                (qof-print-date (gnc:get-today))
                 (gnc:html-markup-br)
               )
             )

commit 5c9432ad8852746722804500d48b208b43396cbf
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Dec 24 06:46:51 2017 +0800

    TP->T64: gnucash/report/stylesheets/stylesheet-footer.scm

diff --git a/gnucash/report/stylesheets/stylesheet-footer.scm b/gnucash/report/stylesheets/stylesheet-footer.scm
index 59c3fb6..77bb318 100644
--- a/gnucash/report/stylesheets/stylesheet-footer.scm
+++ b/gnucash/report/stylesheets/stylesheet-footer.scm
@@ -450,8 +450,8 @@
               (gnc:html-markup-b prepared-for)
               (gnc:html-markup-br)
               (_ "Date: ")
-              (gnc-print-date
-               (cons (current-time) 0)))
+              (qof-print-date
+               (current-time)))
 
              ;; title only 
              (gnc:make-html-text

commit c3c71e79bd5def761b7d2efb3c91e5b3a730f0aa
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Dec 24 06:46:42 2017 +0800

    TP->T64: gnucash/report/stylesheets/stylesheet-fancy.scm

diff --git a/gnucash/report/stylesheets/stylesheet-fancy.scm b/gnucash/report/stylesheets/stylesheet-fancy.scm
index eebdc3a..1ed00d8 100644
--- a/gnucash/report/stylesheets/stylesheet-fancy.scm
+++ b/gnucash/report/stylesheets/stylesheet-fancy.scm
@@ -432,8 +432,8 @@
               (gnc:html-markup-b prepared-for)
               (gnc:html-markup-br)
               (_ "Date: ")
-              (gnc-print-date
-               (cons (current-time) 0)))
+              (qof-print-date
+               (current-time)))
 
              ;; title only 
              (gnc:make-html-text

commit 1b85f9ffe489571ee4ad978b5b965f25fc0199ca
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Dec 24 06:46:30 2017 +0800

    TP->T64: gnucash/report/stylesheets/stylesheet-easy.scm

diff --git a/gnucash/report/business-reports/receipt.eguile.scm b/gnucash/report/business-reports/receipt.eguile.scm
index e0b852b..18c53f2 100644
--- a/gnucash/report/business-reports/receipt.eguile.scm
+++ b/gnucash/report/business-reports/receipt.eguile.scm
@@ -30,8 +30,8 @@
     (let* (; invoice and company details
            (invoiceid  (gncInvoiceGetID         opt-invoice))
            (book       (gncInvoiceGetBook       opt-invoice))
-           (postdate   (gncInvoiceGetDatePostedTT opt-invoice))
-           (duedate    (gncInvoiceGetDateDueTT    opt-invoice))
+           (postdate   (gncInvoiceGetDatePosted opt-invoice))
+           (duedate    (gncInvoiceGetDateDue    opt-invoice))
            (billingid  (gncInvoiceGetBillingID  opt-invoice))
            (notes      (gncInvoiceGetNotes      opt-invoice))
            (terms      (gncInvoiceGetTerms      opt-invoice))
@@ -193,7 +193,7 @@
                   (dsc-total 'add currency rdiscval)
         ?>
         <tr valign="top">
-          <td align="left"><?scm:d (qof-print-date (gncEntryGetDateTT entry)) ?></td>
+          <td align="left"><?scm:d (qof-print-date (gncEntryGetDate entry)) ?></td>
           <td align="left" ><?scm:d (gncEntryGetDescription entry) ?></td>
           <td align="right"><?scm:d (fmtnumeric qty) ?></td>
           <td align="right"><?scm:d (format #f "~4,2,,,'0f" (gnc-numeric-to-double each)) ?></td>
diff --git a/gnucash/report/stylesheets/stylesheet-easy.scm b/gnucash/report/stylesheets/stylesheet-easy.scm
index 38e7fb6..9037c1c 100644
--- a/gnucash/report/stylesheets/stylesheet-easy.scm
+++ b/gnucash/report/stylesheets/stylesheet-easy.scm
@@ -437,8 +437,8 @@
               (gnc:html-markup-b prepared-for)
               (gnc:html-markup-br)
               (_ "Date: ")
-              (gnc-print-date
-               (cons (current-time) 0)))
+              (qof-print-date
+               (current-time)))
 
              ;; title only 
              (gnc:make-html-text

commit c1d61d50810f63c82cd2e674736f569d75fb1db2
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Dec 24 05:36:02 2017 +0800

    TP->T64: gnucash/report/business-reports/receipt.eguile.scm

diff --git a/gnucash/report/business-reports/receipt.eguile.scm b/gnucash/report/business-reports/receipt.eguile.scm
index 3b70108..e0b852b 100644
--- a/gnucash/report/business-reports/receipt.eguile.scm
+++ b/gnucash/report/business-reports/receipt.eguile.scm
@@ -30,8 +30,8 @@
     (let* (; invoice and company details
            (invoiceid  (gncInvoiceGetID         opt-invoice))
            (book       (gncInvoiceGetBook       opt-invoice))
-           (postdate   (gncInvoiceGetDatePosted opt-invoice))
-           (duedate    (gncInvoiceGetDateDue    opt-invoice))
+           (postdate   (gncInvoiceGetDatePostedTT opt-invoice))
+           (duedate    (gncInvoiceGetDateDueTT    opt-invoice))
            (billingid  (gncInvoiceGetBillingID  opt-invoice))
            (notes      (gncInvoiceGetNotes      opt-invoice))
            (terms      (gncInvoiceGetTerms      opt-invoice))
@@ -68,8 +68,8 @@
                      (lambda (s1 s2)
                        (let ((t1 (xaccSplitGetParent s1))
                              (t2 (xaccSplitGetParent s2)))
-                         (< (car (gnc-transaction-get-date-posted t1))
-                            (car (gnc-transaction-get-date-posted t2))))))))
+                         (< (xaccTransGetDate t1)
+                            (xaccTransGetDate t2)))))))
 
       ; pre-scan invoice entries to look for discounts and taxes
       (for entry in entries do
@@ -142,7 +142,7 @@
   <!-- header texts -->
 
   <h1><?scm:d (nbsp (_ "Invoice No.")) ?> <?scm:d invoiceid ?></h1>
-  <h2><?scm:d (strftime	opt-date-format (localtime (car (gnc:get-today)))) ?></h2>
+  <h2><?scm:d (strftime	opt-date-format (localtime (gnc:get-today))) ?></h2>
   <p> </p>
   <?scm (if (not (string=? billcontact "")) (begin ?>
     <p>Attn: <?scm:d billcontact ?></p><br>
@@ -193,7 +193,7 @@
                   (dsc-total 'add currency rdiscval)
         ?>
         <tr valign="top">
-          <td align="left"><?scm:d (gnc-print-date (gncEntryGetDate entry)) ?></td>
+          <td align="left"><?scm:d (qof-print-date (gncEntryGetDateTT entry)) ?></td>
           <td align="left" ><?scm:d (gncEntryGetDescription entry) ?></td>
           <td align="right"><?scm:d (fmtnumeric qty) ?></td>
           <td align="right"><?scm:d (format #f "~4,2,,,'0f" (gnc-numeric-to-double each)) ?></td>
@@ -254,7 +254,7 @@
                       (inv-total 'add c a)
         ?>
         <tr valign="top">
-          <td align="center"><?scm:d (gnc-print-date (gnc-transaction-get-date-posted t)) ?></td>
+          <td align="center"><?scm:d (qof-print-date (xaccTransGetDate t)) ?></td>
           <td align="left" colspan="<?scm:d (- maxcols 3) ?>"><?scm:d opt-payment-recd-heading ?></td>
           <td align="right" colspan="2"><?scm:d (fmtmoney c a) ?></td>
         </tr>

commit 9422d4aed677b98167794e7712d5b26379689058
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Dec 24 05:35:36 2017 +0800

    TP->T64: gnucash/report/business-reports/invoice.scm

diff --git a/gnucash/report/business-reports/invoice.scm b/gnucash/report/business-reports/invoice.scm
index 814a873..a54f02e 100644
--- a/gnucash/report/business-reports/invoice.scm
+++ b/gnucash/report/business-reports/invoice.scm
@@ -161,7 +161,7 @@
 
     (if (date-col column-vector)
         (addto! row-contents
-                (gnc-print-date (gncEntryGetDate entry))))
+                (qof-print-date (gncEntryGetDate entry))))
 
     (if (description-col column-vector)
         (addto! row-contents
@@ -404,7 +404,7 @@
 
 	(if (date-col used-columns)
 	    (addto! row
-		    (gnc-print-date (gnc-transaction-get-date-posted t))))
+		    (qof-print-date (xaccTransGetDate t))))
 
 	(if (description-col used-columns)
 	    (addto! row (_ "Payment, thank you")))
@@ -587,7 +587,7 @@
    (list
     (string-append label ": ")
     (string-expand (strftime date-format
-                             (localtime (car date)))
+                             (localtime date))
                              #\space " ")
     )))
 
@@ -621,7 +621,7 @@
     (gnc:html-table-append-row! table (list
 				       (strftime
 					date-format
-					(gnc-localtime (car (gnc:get-today))))))
+					(gnc-localtime (gnc:get-today)))))
     table))
 
 (define (make-break! document)
@@ -712,7 +712,7 @@
 		(post-date (gncInvoiceGetDatePosted invoice))
 		(due-date (gncInvoiceGetDateDue invoice)))
 
-	    (if (not (equal? post-date (cons 0 0)))
+	    (if (not (zero? post-date))
 		(begin
 		  (set! date-table (make-date-table))
 		  (make-date-row! date-table (string-append title " " (_ "Date")) post-date date-format)

commit 42b43250d66b22467b829e7c71822b2059298123
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Dec 24 05:35:20 2017 +0800

    TP->T64: gnucash/report/business-reports/fancy-invoice.scm

diff --git a/gnucash/report/business-reports/fancy-invoice.scm b/gnucash/report/business-reports/fancy-invoice.scm
index 2a41c1c..3a2cf58 100644
--- a/gnucash/report/business-reports/fancy-invoice.scm
+++ b/gnucash/report/business-reports/fancy-invoice.scm
@@ -174,7 +174,7 @@
 
     (if (date-col column-vector)
         (addto! row-contents
-                (gnc-print-date (gncEntryGetDate entry))))
+                (qof-print-date (gncEntryGetDate entry))))
 
     (if (description-col column-vector)
         (addto! row-contents
@@ -455,7 +455,7 @@
 
 	(if (date-col used-columns)
 	    (addto! row
-		    (gnc-print-date (gnc-transaction-get-date-posted t))))
+		    (qof-print-date (xaccTransGetDate t))))
 
 	(if (description-col used-columns)
 	    (addto! row (_ "Payment, thank you")))
@@ -663,9 +663,9 @@
     ;; for the invoice date/due date fields
     ;; I could have taken the format from the report options, but... ;)
     (string-expand (strftime (gnc-default-strftime-date-format)
-                             (gnc-localtime (car date)))
+                             (gnc-localtime date))
                    #\space " ")
-    ;;(string-expand (gnc-print-date date) #\space " ")
+    ;;(string-expand (qof-print-date date) #\space " ")
     )))
 
 (define (make-date-table)
@@ -740,7 +740,7 @@
 ;;    (gnc:html-table-append-row! table (list
 ;;				       (strftime
 ;;					date-format
-;;					(gnc-localtime (car (gnc:get-today))))))
+;;					(gnc-localtime (gnc:get-today)))))
     table))
 
 (define (make-break! document)
@@ -861,7 +861,7 @@
 		(post-date (gncInvoiceGetDatePosted invoice))
 		(due-date (gncInvoiceGetDateDue invoice)))
 
-	    (if (not (equal? post-date (cons 0 0)))
+	    (if (not (zero? post-date))
 		(begin
 		  (set! date-table (make-date-table))
 		  ;; oli-custom - moved invoice number here

commit 5a2d47219fa13be155c6a84d13dd056fb8c00614
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Dec 24 05:34:52 2017 +0800

    TP->T64: gnucash/report/business-reports/easy-invoice.scm

diff --git a/gnucash/report/business-reports/easy-invoice.scm b/gnucash/report/business-reports/easy-invoice.scm
index 3e6bbbe..de14f36 100644
--- a/gnucash/report/business-reports/easy-invoice.scm
+++ b/gnucash/report/business-reports/easy-invoice.scm
@@ -166,7 +166,7 @@
 
     (if (date-col column-vector)
         (addto! row-contents
-                (gnc-print-date (gncEntryGetDate entry))))
+                (qof-print-date (gncEntryGetDate entry))))
 
     (if (description-col column-vector)
         (addto! row-contents
@@ -426,7 +426,7 @@
 
 	(if (date-col used-columns)
 	    (addto! row
-		    (gnc-print-date (gnc-transaction-get-date-posted t))))
+		    (qof-print-date (xaccTransGetDate t))))
 
 	(if (description-col used-columns)
 	    (addto! row (_ "Payment, thank you")))
@@ -611,7 +611,7 @@
    (list
     (string-append label ": ")
     (string-expand (strftime date-format
-                             (localtime (car date)))
+                             (localtime date))
                              #\space " "))))
 
 (define (make-date-table)
@@ -780,7 +780,7 @@
         (let ((date-table #f)
               (post-date (gncInvoiceGetDatePosted invoice))
               (due-date (gncInvoiceGetDateDue invoice)))
-          (if (not (equal? post-date (cons 0 0)))
+          (if (not (zero? post-date))
             (begin
               (set! date-table (make-date-table))
               (make-date-row! date-table (_ "Date") post-date date-format)

commit 345ea0abc3dbe52f40658f5bbb0ce277284eeeac
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri Dec 22 22:21:27 2017 +0800

    TP->T64: gnucash/report/business-reports/job-report.scm

diff --git a/gnucash/report/business-reports/job-report.scm b/gnucash/report/business-reports/job-report.scm
index c45b121..590875d 100644
--- a/gnucash/report/business-reports/job-report.scm
+++ b/gnucash/report/business-reports/job-report.scm
@@ -118,9 +118,9 @@
 
 (define (make-interval-list to-date)
   (let ((begindate to-date))
-    (set! begindate (decdate begindate ThirtyDayDelta))
-    (set! begindate (decdate begindate ThirtyDayDelta))
-    (set! begindate (decdate begindate ThirtyDayDelta))
+    (set! begindate (decdate64 begindate ThirtyDayDelta))
+    (set! begindate (decdate64 begindate ThirtyDayDelta))
+    (set! begindate (decdate64 begindate ThirtyDayDelta))
     (gnc:make-date-list begindate to-date ThirtyDayDelta)))
 
 
@@ -132,7 +132,7 @@
 	(table (gnc:make-html-table)))
 
     (define (in-interval this-date current-bucket)
-      (gnc:timepair-lt this-date current-bucket))
+      (< this-date current-bucket))
 
     (define (find-bucket current-bucket bucket-intervals date)
       (begin
@@ -189,12 +189,12 @@
 (define (make-row column-vector date due-date num type-str memo monetary)
   (let ((row-contents '()))
     (if (date-col column-vector)
-	(addto! row-contents (gnc-print-date date)))
+	(addto! row-contents (qof-print-date date)))
     (if (date-due-col column-vector)
 	(addto! row-contents 
 		(if (and due-date
-			 (not (equal? due-date (cons 0 0))))
-		    (gnc-print-date due-date)
+			 (not (zero? due-date)))
+		    (qof-print-date due-date)
 		    "")))
     (if (num-col column-vector)
 	(addto! row-contents num))
@@ -236,7 +236,7 @@
 (define (add-txn-row table txn acc column-vector odd-row? printed?
 		     inv-str reverse? start-date total)
   (let* ((type (xaccTransGetTxnType txn))
-	 (date (gnc-transaction-get-date-posted txn))
+	 (date (xaccTransGetDate txn))
 	 (due-date #f)
 	 (value (xaccTransGetAccountValue txn acc))
 	 (split (xaccTransGetSplit txn 0))
@@ -258,7 +258,7 @@
     (if reverse?
 	(set! value (gnc-numeric-neg value)))
 
-    (if (gnc:timepair-later start-date date)
+    (if (< start-date date)
 	(begin
 	  
 	  ; Adds 'balance' row if needed
@@ -465,7 +465,7 @@
      guid QOF-QUERY-OR)
 
     (xaccQueryAddSingleAccountMatch q account QOF-QUERY-AND)
-    (xaccQueryAddDateMatchTS q #f end-date #t end-date QOF-QUERY-AND)
+    (xaccQueryAddDateMatchTT q #f end-date #t end-date QOF-QUERY-AND)
     (qof-query-set-book q (gnc-get-current-book))
     q))
 
@@ -493,7 +493,7 @@
    table
    (list
     (string-append label ": ")
-    (string-expand (gnc-print-date date) #\space " "))))
+    (string-expand (qof-print-date date) #\space " "))))
 
 (define (make-date-table)
   (let ((table (gnc:make-html-table)))
@@ -526,7 +526,7 @@
     (gnc:html-table-append-row! table (list
 				       (strftime
 					date-format
-					(gnc-localtime (car (gnc:get-today))))))
+					(gnc-localtime (current-time)))))
     table))
 
 (define (make-break! document)
@@ -546,10 +546,10 @@
 	 (query (qof-query-create-for-splits))
 	 (account (opt-val owner-page acct-string))
 	 (owner (opt-val owner-page owner-string))
-	 (start-date (gnc:timepair-start-day-time 
+	 (start-date (gnc:time64-start-day-time 
 		       (gnc:date-option-absolute-time
 			(opt-val gnc:pagename-general (N_ "From")))))
-	 (end-date (gnc:timepair-end-day-time 
+	 (end-date (gnc:time64-end-day-time 
 		       (gnc:date-option-absolute-time
 			(opt-val gnc:pagename-general (N_ "To")))))
 	 (book (gnc-account-get-book account))
@@ -620,9 +620,9 @@
 	    (string-append
 	     (_ "Date Range")
 	     ": "
-	     (gnc-print-date start-date)
+	     (qof-print-date start-date)
 	     " - "
-	     (gnc-print-date end-date))))
+	     (qof-print-date end-date))))
 
 	  (make-break! document)
 

commit e44df79b88a0909421d040f6fe42fbf6777b44b0
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Thu Dec 21 22:47:18 2017 +0800

    TP->T64: gnucash/report/business-reports/balsheet-eg[.eguile].scm

diff --git a/gnucash/report/business-reports/balsheet-eg.eguile.scm b/gnucash/report/business-reports/balsheet-eg.eguile.scm
index 4066ad5..1bcec52 100644
--- a/gnucash/report/business-reports/balsheet-eg.eguile.scm
+++ b/gnucash/report/business-reports/balsheet-eg.eguile.scm
@@ -128,7 +128,7 @@
 <html>
 <head>
 <meta http-equiv="content-type" content="text-html; charset=utf-8">
-<title><?scm:d coyname ?> <?scm:d reportname ?> <?scm:d (gnc-print-date opt-date-tp) ?></title>
+<title><?scm:d coyname ?> <?scm:d reportname ?> <?scm:d (qof-print-date opt-date) ?></title>
 
 <?scm (if css? (begin ?>
 <link rel="stylesheet" href="<?scm:d opt-css-file ?>" type="text/css">
@@ -157,7 +157,7 @@
   <table border="0" cellpadding="16"><tr><td> <!-- hack for GTKHTML -->
 <?scm )) ?>
 <h3><?scm:d coyname ?></h3>
-<h2><?scm:d reportname ?> <?scm:d (gnc-print-date opt-date-tp) ?></h2>
+<h2><?scm:d reportname ?> <?scm:d (qof-print-date opt-date) ?></h2>
 
 <?scm
   ;; This is where the work is done.
diff --git a/gnucash/report/business-reports/balsheet-eg.scm b/gnucash/report/business-reports/balsheet-eg.scm
index 5df41b6..96cfa52 100644
--- a/gnucash/report/business-reports/balsheet-eg.scm
+++ b/gnucash/report/business-reports/balsheet-eg.scm
@@ -381,10 +381,9 @@
          (opt-price-source     (get-option commodities-page optname-price-source))
          (opt-show-foreign?    (get-option commodities-page optname-show-foreign))
          (opt-report-title     (get-option general-page     optname-report-title))
-         (opt-date-tp          (gnc:timepair-end-day-time
+         (opt-date             (gnc:time64-end-day-time
                                  (gnc:date-option-absolute-time
                                    (get-option general-page optname-date))))
-         (opt-date-secs        (gnc:timepair->secs          opt-date-tp))
          (opt-columns          (get-option display-page     optname-columns))
          (opt-font-family      (get-option display-page     optname-font-family))
          (opt-font-size        (get-option display-page     optname-font-size))
@@ -424,7 +423,7 @@
 
          ;; exchange rates calculation parameters
          (exchange-fn
-           (gnc:case-exchange-fn opt-price-source opt-report-commodity opt-date-tp))
+           (gnc:case-exchange-fn opt-price-source opt-report-commodity opt-date))
          ; List of commodities (other than the local one) used
          ; so that exchange rate table can be displayed.
          ; xlist will become an association list of (comm . #t) pairs
@@ -524,7 +523,7 @@
                       (>= (gnc-account-get-current-depth (car account-list)) curr-depth))
                  (let* ((account (car account-list))
                         (comm    (xaccAccountGetCommodity account))
-                        (bal     (xaccAccountGetBalanceAsOfDate account opt-date-secs))
+                        (bal     (xaccAccountGetBalanceAsOfDate account opt-date))
                         (depth   (flattened-acc-depth account))
                         (treedepth 1)
                         ; Next account only qualifies as 'deeper' if we're not flattening

commit e2c353fac616f59b61f587278e242608998fc79e
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue Dec 19 07:19:27 2017 +0800

    TP->T64: gnucash/report/business-reports/taxinvoice.eguile.scm

diff --git a/gnucash/report/business-reports/taxinvoice.eguile.scm b/gnucash/report/business-reports/taxinvoice.eguile.scm
index 1fc7189..159fec7 100644
--- a/gnucash/report/business-reports/taxinvoice.eguile.scm
+++ b/gnucash/report/business-reports/taxinvoice.eguile.scm
@@ -79,8 +79,8 @@
                      (lambda (s1 s2)
                        (let ((t1 (xaccSplitGetParent s1))
                              (t2 (xaccSplitGetParent s2)))
-                         (< (car (gnc-transaction-get-date-posted t1))
-                            (car (gnc-transaction-get-date-posted t2))))))))
+                         (< (xaccTransGetDate t1)
+                            (xaccTransGetDate t2)))))))
 
 
       ;; Is this an invoice or something else
@@ -246,7 +246,7 @@
         <td align="right" class="invnum"><big><strong><?scm:d invoiceid ?></strong></big></td>
       </tr>
       <?scm )) ?>
-      <?scm (if (equal? postdate (cons 0 0)) (begin ?>
+      <?scm (if (zero? postdate) (begin ?>
         <tr>
            <td colspan="2" align="right"><?scm:d (_ "Invoice in progress...") ?></td>
         </tr>
@@ -254,12 +254,12 @@
         <tr>
            <td align="right"><?scm:d (nbsp (_ "Invoice Date")) ?>: </td>
            <td align="right"><?scm:d (nbsp (strftime dateformat
-                                            (localtime (car postdate)))) ?></td>
+                                            (localtime postdate))) ?></td>
         </tr>
         <tr>
            <td align="right"><?scm:d (nbsp (_ "Due Date")) ?>: </td>
            <td align="right"><?scm:d (nbsp (strftime dateformat
-                                            (localtime (car duedate)))) ?></td>
+                                            (localtime duedate))) ?></td>
         </tr> <?scm )) ?>
         <?scm (if (not (string=? billingid "")) (begin ?>
           <tr>
@@ -347,7 +347,7 @@
     ?>
     <tr valign="top">
       <?scm (if opt-col-date (begin ?>
-      <td align="center" ><nobr><?scm:d (nbsp (gnc-print-date (gncEntryGetDate entry))) ?></nobr></td>
+      <td align="center" ><nobr><?scm:d (nbsp (qof-print-date (gncEntryGetDate entry))) ?></nobr></td>
       <?scm )) ?>
       <td align="left"><?scm:d (gncEntryGetDescription entry) ?></td>
       <!-- td align="left">< ?scm:d (gncEntryGetNotes entry) ?></td -->
@@ -419,7 +419,7 @@
     ?>
     <tr valign="top">
       <?scm (if opt-col-date (begin ?>
-      <td align="center"><?scm:d (gnc-print-date (gnc-transaction-get-date-posted t)) ?></td>
+      <td align="center"><?scm:d (qof-print-date (xaccTransGetDate t)) ?></td>
       <?scm )) ?>
       <td align="left" colspan="<?scm:d (+ tbl_cols (if opt-col-date 0 1)) ?>"><?scm:d opt-payment-recd-heading ?></td>
       <td align="right"><?scm:d (fmtmoney c a) ?></td>

commit a16532a912bc46887514443b48daaf500a0cc288
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue Dec 19 07:17:59 2017 +0800

    TP->T64: gnucash/report/business-reports/owner-report.scm

diff --git a/gnucash/report/business-reports/owner-report.scm b/gnucash/report/business-reports/owner-report.scm
index 3dd6563..0516f69 100644
--- a/gnucash/report/business-reports/owner-report.scm
+++ b/gnucash/report/business-reports/owner-report.scm
@@ -204,14 +204,14 @@
 
 (define (make-interval-list to-date)
   (let ((begindate to-date))
-    (set! begindate (decdate begindate ThirtyDayDelta))
-    (set! begindate (decdate begindate ThirtyDayDelta))
-    (set! begindate (decdate begindate ThirtyDayDelta))
+    (set! begindate (decdate64 begindate ThirtyDayDelta))
+    (set! begindate (decdate64 begindate ThirtyDayDelta))
+    (set! begindate (decdate64 begindate ThirtyDayDelta))
     (gnc:make-date-list begindate to-date ThirtyDayDelta)))
 
 ;; Have make-list create a stepped list, then add a date in the future for the "current" bucket 
 (define (make-extended-interval-list to-date) 
-    (define dayforcurrent (incdate to-date YearDelta)) ;; MAGIC CONSTANT 
+    (define dayforcurrent (incdate64 to-date YearDelta)) ;; MAGIC CONSTANT 
     (define oldintervalreversed (reverse (make-interval-list to-date)))          
     (reverse (cons dayforcurrent oldintervalreversed))) 
 
@@ -222,7 +222,7 @@
     (table (gnc:make-html-table)))
 
      (define (in-interval this-date current-bucket)
-      (gnc:timepair-lt this-date current-bucket))
+      (< this-date current-bucket))
 
      (define (find-bucket current-bucket bucket-intervals date)
       (begin
@@ -247,7 +247,7 @@
        (let* ((bal (gnc-lot-get-balance lot))
           (invoice (gncInvoiceGetInvoiceFromLot lot))
               (date (if (eq? date-type 'postdate)
-               (gncInvoiceGetDatePosted invoice) 
+               (gncInvoiceGetDatePostedTT invoice) 
                (gncInvoiceGetDateDue invoice)))
               )
          
@@ -283,12 +283,12 @@
 (define (make-row column-vector date due-date num type-str memo monetary credit debit sale tax)
   (let ((row-contents '()))
     (if (date-col column-vector)
-        (addto! row-contents (gnc-print-date date)))
+        (addto! row-contents (qof-print-date date)))
     (if (date-due-col column-vector)
         (addto! row-contents 
          (if (and due-date
-              (not (equal? due-date (cons 0 0))))
-             (gnc-print-date due-date)
+              (not (zero? due-date)))
+             (qof-print-date due-date)
              "")))
     (if (num-col column-vector)
         (addto! row-contents num))
@@ -342,7 +342,7 @@
 (define (add-txn-row table txn acc column-vector odd-row? printed?
              reverse? start-date total)
   (let* ((type (xaccTransGetTxnType txn))
-     (date (gnc-transaction-get-date-posted txn))
+     (date (xaccTransGetDate txn))
      (due-date #f)
      (value (xaccTransGetAccountValue txn acc))
      (sale (gnc-numeric-zero))
@@ -369,7 +369,7 @@
    (if reverse?
     (set! value (gnc-numeric-neg value)))
 
-   (if (gnc:timepair-le start-date date)
+   (if (<= start-date date)
     (begin
       
       ; Adds 'balance' row if needed
@@ -670,7 +670,7 @@
      guid QOF-QUERY-OR)
 
     (xaccQueryAddSingleAccountMatch q account QOF-QUERY-AND)
-    (xaccQueryAddDateMatchTS q #f end-date #t end-date QOF-QUERY-AND)
+    (xaccQueryAddDateMatchTT q #f end-date #t end-date QOF-QUERY-AND)
     (qof-query-set-book q (gnc-get-current-book))
     q))
 
@@ -698,7 +698,7 @@
    table
    (list
     (string-append label ": ")
-    (string-expand (gnc-print-date date) #\space " "))))
+    (string-expand (qof-print-date date) #\space " "))))
 
 (define (make-date-table)
   (let ((table (gnc:make-html-table)))
@@ -731,7 +731,7 @@
     (gnc:html-table-append-row! table (list
                        (strftime
                     date-format
-                    (gnc-localtime (car (gnc:get-today))))))
+                    (gnc-localtime (gnc:get-today)))))
     table))
 
 (define (make-break! document)
@@ -750,10 +750,10 @@
      (orders '())
      (query (qof-query-create-for-splits))
      (account (opt-val owner-page acct-string))
-     (start-date (gnc:timepair-start-day-time 
+     (start-date (gnc:time64-start-day-time 
       (gnc:date-option-absolute-time
        (opt-val gnc:pagename-general optname-from-date))))
-     (end-date (gnc:timepair-end-day-time 
+     (end-date (gnc:time64-end-day-time 
                (gnc:date-option-absolute-time
                (opt-val gnc:pagename-general optname-to-date))))
      (book (gnc-account-get-book account))
@@ -816,9 +816,9 @@
           (string-append
            (_ "Date Range")
            ": "
-           (gnc-print-date start-date)
+           (qof-print-date start-date)
            " - "
-           (gnc-print-date end-date))))
+           (qof-print-date end-date))))
 
         (make-break! document)
 

commit 629abc3caf471b94172a040fc790e9183901bc0f
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Dec 17 23:49:02 2017 +0800

    TP->T64: gnucash/report/business-reports/customer-summary.scm

diff --git a/gnucash/report/business-reports/customer-summary.scm b/gnucash/report/business-reports/customer-summary.scm
index 9124344..9f062e7 100644
--- a/gnucash/report/business-reports/customer-summary.scm
+++ b/gnucash/report/business-reports/customer-summary.scm
@@ -158,7 +158,7 @@
 (define (make-row column-vector date due-date num type-str memo monetary)
   (let ((row-contents '()))
     (if (date-col column-vector)
-        (addto! row-contents (gnc-print-date date)))
+        (addto! row-contents (qof-print-date date)))
     (if (num-col column-vector)
         (addto! row-contents num))
     (if (type-col column-vector)
@@ -199,7 +199,7 @@
 (define (add-txn-row table txn acc column-vector odd-row? printed?
                      inv-str reverse? start-date total)
   (let* ((type (xaccTransGetTxnType txn))
-         (date (gnc-transaction-get-date-posted txn))
+         (date (xaccTransGetDate txn))
          (due-date #f)
          (value (xaccTransGetAccountValue txn acc))
          (split (xaccTransGetSplit txn 0))
@@ -227,7 +227,7 @@
     (if reverse?
         (set! value (gnc-numeric-neg value)))
 
-    (if (gnc:timepair-later start-date date)
+    (if (< start-date date)
         (begin
           
           ;; Adds 'balance' row if needed
@@ -235,7 +235,7 @@
           
           ;; Now print out the invoice row
           (if (not (null? invoice))
-              (set! due-date (gncInvoiceGetDateDue invoice)))
+              (set! due-date (gncInvoiceGetDateDueTT invoice)))
 
           (let ((row (make-row column-vector date due-date (gnc-get-num-action txn split)
                                type-str (xaccSplitGetMemo split)
@@ -538,7 +538,7 @@
 
 (define (query-toplevel-setup query account-list start-date end-date)
   (xaccQueryAddAccountMatch query account-list QOF-GUID-MATCH-ANY QOF-QUERY-AND)
-  (xaccQueryAddDateMatchTS query #t start-date #t end-date QOF-QUERY-AND)
+  (xaccQueryAddDateMatchTT query #t start-date #t end-date QOF-QUERY-AND)
   (qof-query-set-book query (gnc-get-current-book))
   query)
 
@@ -598,7 +598,7 @@
    table
    (list
     (string-append label ": ")
-    (string-expand (gnc-print-date date) #\space " "))))
+    (string-expand (qof-print-date date) #\space " "))))
 
 (define (make-date-table)
   (let ((table (gnc:make-html-table)))
@@ -633,7 +633,7 @@
     (gnc:html-table-append-row! table (list
                                        (strftime
                                         date-format
-                                        (localtime (car (gnc:get-today))))))
+                                        (localtime (gnc:get-today)))))
 
     (gnc:html-table-set-style!
      table-outer "table"
@@ -688,10 +688,10 @@
 
   (let* ((document (gnc:make-html-document))
          (report-title (opt-val gnc:pagename-general gnc:optname-reportname))
-         (start-date (gnc:timepair-start-day-time 
+         (start-date (gnc:time64-start-day-time 
                       (gnc:date-option-absolute-time
                        (opt-val gnc:pagename-general optname-from-date))))
-         (end-date (gnc:timepair-end-day-time 
+         (end-date (gnc:time64-end-day-time 
                     (gnc:date-option-absolute-time
                      (opt-val gnc:pagename-general optname-to-date))))
          (print-invoices? #t);;(opt-val gnc:pagename-general optname-invoicelines))
@@ -995,8 +995,8 @@
                (sprintf
                 #f (_ "%s %s - %s")
                 report-title
-                (gnc-print-date start-date)
-                (gnc-print-date end-date))))
+                (qof-print-date start-date)
+                (qof-print-date end-date))))
           (gnc:html-document-set-title!
            document headline)
 

commit d43df09368c661dcb5e2811e5baee12228c02ee5
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Dec 18 00:05:55 2017 +0800

    TP->T64: gnucash/report/business-reports/aging.scm to time64

diff --git a/gnucash/report/business-reports/aging.scm b/gnucash/report/business-reports/aging.scm
index cd3e60f..1ac7031 100644
--- a/gnucash/report/business-reports/aging.scm
+++ b/gnucash/report/business-reports/aging.scm
@@ -112,7 +112,7 @@
 
 (define (process-invoice company amount bucket-intervals date)
   (define (in-interval this-date current-bucket)
-    (gnc:timepair-lt this-date current-bucket))
+    (< this-date current-bucket))
 
   (define (find-bucket current-bucket bucket-intervals date)  
     (gnc:debug "looking for bucket for date: " date)
@@ -183,8 +183,8 @@
 ;; determine date function to use 
 (define (get-selected-date-from-txn transaction date-type)
   (if (eq? date-type 'postdate)
-      (gnc-transaction-get-date-posted transaction)
-      (xaccTransRetDateDueTS transaction)))		    
+      (xaccTransGetDate transaction)
+      (xaccTransRetDateDue transaction)))
   
 ;; deal with a transaction - figure out if we've seen the company before
 ;; if so, either process it as a bill or a payment, if not, create
@@ -315,16 +315,14 @@ more than one currency. This report is not designed to cope with this possibilit
 ;; set up the query to get the splits in the chosen account
 ;; XXX: FIXME: begindate is a hack -- we currently only go back a year
 (define (setup-query query account date)
-  (define (date-copy date)
-    (cons (car date) (cdr date)))
-  (let ((begindate (make-zdate))) ;Set begindate to the start of the Epoch
+  (let ((begindate (gnc-mktime (make-zdate)))) ;Set begindate to the start of the Epoch
 ;    (gnc:debug "Account: " account)
     (gnc:debug "begindate" begindate)
     (gnc:debug "date" date)
     (qof-query-set-book query (gnc-get-current-book))
     (gnc:query-set-match-non-voids-only! query (gnc-get-current-book))
     (xaccQueryAddSingleAccountMatch query account QOF-QUERY-AND)
-    (xaccQueryAddDateMatchTS query #t begindate #t date QOF-QUERY-AND)
+    (xaccQueryAddDateMatchTT query #t begindate #t date QOF-QUERY-AND)
     (qof-query-set-sort-order query
 			      (list SPLIT-TRANS TRANS-DATE-POSTED)
 			      '() '())
@@ -489,14 +487,14 @@ copying this report to a spreadsheet for use in a mail merge.")
 
 (define (make-interval-list to-date)
   (let ((begindate to-date))
-    (set! begindate (decdate begindate ThirtyDayDelta))
-    (set! begindate (decdate begindate ThirtyDayDelta))
-    (set! begindate (decdate begindate ThirtyDayDelta))
+    (set! begindate (decdate64 begindate ThirtyDayDelta))
+    (set! begindate (decdate64 begindate ThirtyDayDelta))
+    (set! begindate (decdate64 begindate ThirtyDayDelta))
     (gnc:make-date-list begindate to-date ThirtyDayDelta)))
 
 ;; Have make-list create a stepped list, then add a date in the future for the "current" bucket
 (define (make-extended-interval-list to-date)
-    (define dayforcurrent (incdate to-date YearDelta)) ;; MAGIC CONSTANT
+    (define dayforcurrent (incdate64 to-date YearDelta)) ;; MAGIC CONSTANT
     (define oldintervalreversed (reverse (make-interval-list to-date)))		
   (reverse (cons dayforcurrent oldintervalreversed)))
 
@@ -657,7 +655,7 @@ copying this report to a spreadsheet for use in a mail merge.")
   (let* ((companys (make-hash-table 23))
 	 (report-title (op-value gnc:pagename-general gnc:optname-reportname))
         ;; document will be the HTML document that we return.
-	(report-date (gnc:timepair-end-day-time 
+	(report-date (gnc:time64-end-day-time 
 		      (gnc:date-option-absolute-time
 		       (op-value gnc:pagename-general optname-to-date))))
 	(interval-vec (list->vector (make-extended-interval-list report-date)))

commit fada13e456076e44a7b83c823f42fd3a913fc7ea
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Dec 23 15:56:22 2017 +0800

    TP->T64: gnucash/report/locale-specific/us/taxtxf-de_DE.scm

diff --git a/gnucash/report/locale-specific/us/taxtxf-de_DE.scm b/gnucash/report/locale-specific/us/taxtxf-de_DE.scm
index 62130fb..ffd60e5 100644
--- a/gnucash/report/locale-specific/us/taxtxf-de_DE.scm
+++ b/gnucash/report/locale-specific/us/taxtxf-de_DE.scm
@@ -91,19 +91,18 @@
 
 (define levelx-collector (make-level-collector MAX-LEVELS))
 
-(define today (timespecCanonicalDayTime
-               (cons (current-time) 0)))
+(define today (time64CanonicalDayTime (current-time)))
 
 (define bdtm
-  (let ((result (gnc:timepair->date today)))
+  (let ((result (gnc-localtime today)))
     (set-tm:mday result 16)             ; 16
     (set-tm:mon result 3)               ; Apr
     (set-tm:isdst result -1)
     result))
 
-(define tax-day (cons (gnc-mktime bdtm) 0))
+(define tax-day (gnc-mktime bdtm))
 
-(define after-tax-day (gnc:timepair-later tax-day today))
+(define after-tax-day (< tax-day today))
 
 (define (make-split-list account split-filter-pred)
   (reverse (filter split-filter-pred
@@ -111,14 +110,14 @@
 
 ;; returns a predicate that returns true only if a split is
 ;; between early-date and late-date
-(define (split-report-make-date-filter-predicate begin-date-tp
-                                                 end-date-tp)
+(define (split-report-make-date-filter-predicate begin-date
+                                                 end-date)
   (lambda (split) 
-    (let ((tp
-           (gnc-transaction-get-date-posted
+    (let ((t
+           (xaccTransGetDate
             (xaccSplitGetParent split))))
-      (and (gnc:timepair-ge-date tp begin-date-tp)
-           (gnc:timepair-le-date tp end-date-tp)))))
+      (and (>= t begin-date)
+           (<= t end-date)))))
 
 ;; This is nearly identical to, and could be shared with
 ;; display-report-list-item in report.scm. This adds warn-msg parameter
@@ -322,10 +321,10 @@
         (let* ((type (xaccAccountGetType account))
                (code (gnc:account-get-txf-code account))
                (date-str (if date
-                             (strftime "%d.%m.%Y" (gnc-localtime (car date)))
+                             (strftime "%d.%m.%Y" (gnc-localtime date))
                              #f))
                (x-date-str (if x-date
-                               (strftime "%d.%m.%Y" (gnc-localtime (car x-date)))
+                               (strftime "%d.%m.%Y" (gnc-localtime x-date))
                                #f))
                ;; Only formats 1,3 implemented now! Others are treated as 1.
                (format (gnc:get-txf-format code (eq? type ACCT-TYPE-INCOME)))
@@ -410,7 +409,7 @@
 (define (render-level-x-account table level max-level account lx-value
                                 suppress-0 full-names txf-date)
   (let* ((account-name (if txf-date	; special split
-                           (strftime "%d.%m.%Y" (gnc-localtime (car txf-date)))
+                           (strftime "%d.%m.%Y" (gnc-localtime txf-date))
                            (if (or full-names (equal? level 1))
                                (gnc-account-get-full-name account)
                                (xaccAccountGetName account))))
@@ -490,7 +489,7 @@
   (gnc:report-starting reportname)
   (let* ((from-value (gnc:date-option-absolute-time 
                       (get-option gnc:pagename-general "From")))
-         (to-value (gnc:timepair-end-day-time
+         (to-value (gnc:time64-end-day-time
                     (gnc:date-option-absolute-time 		       
                      (get-option gnc:pagename-general "To"))))
          (alt-period (get-option gnc:pagename-general "Alternate Period"))
@@ -517,8 +516,8 @@
 	 (work-done 0)
 
          ;; Alternate dates are relative to from-date
-         (from-date (gnc:timepair->date from-value))
-         (from-value (gnc:timepair-start-day-time
+         (from-date (gnc-localtime from-value))
+         (from-value (gnc:time64-start-day-time
                       (let ((bdtm from-date))
                         (if (member alt-period 
                                     '(last-year 1st-last 2nd-last
@@ -547,9 +546,9 @@
                               ((4th-est 4th-last) ; Oct 1
                                (set-tm:mon bdtm 9))))
                         (set-tm:isdst bdtm -1)
-                        (cons (gnc-mktime bdtm) 0))))
+                        (gnc-mktime bdtm))))
 
-         (to-value (gnc:timepair-end-day-time
+         (to-value (gnc:time64-end-day-time
                     (let ((bdtm from-date))
                       (if (member alt-period 
                                   '(last-year 1st-last 2nd-last
@@ -573,8 +572,8 @@
                             ((3rd-est 3rd-last) ; Aug 31
                              (set-tm:mon bdtm 7))
                             ((4th-est 4th-last last-year) ; Dec 31
-                             (set-tm:mon bdtm 11))
-                            (else (set! bdtm (gnc:timepair->date to-value))))
+                             (set-tm:mon bdtm 11)) 
+                            (else (set! bdtm (gnc-mktime to-value))))
                           ;; Tax quaters equal Real quarters
                           (case alt-period
                             ((1st-est 1st-last) ; Mar 31
@@ -588,9 +587,9 @@
                             ((4th-est 4th-last last-year) ; Dec 31
                              (set-tm:mon bdtm 11))
                             (else 
-                             (set! bdtm (gnc:timepair->date to-value)))))
+                             (set! bdtm (gnc-mktime to-value)))))
                       (set-tm:isdst bdtm -1)
-                      (cons (gnc-mktime bdtm) 0))))
+                      (gnc-mktime bdtm))))
 
          (txf-feedback-str-lst '())
          (doc (gnc:make-html-document))
@@ -603,8 +602,8 @@
                (txf-special-split? (gnc:account-get-txf-code account)))
           (let* 
               ((full-year?
-                (let ((bdto (gnc-localtime (car to-value)))
-                      (bdfrom (gnc-localtime (car from-value))))
+                (let ((bdto (gnc-localtime to-value))
+                      (bdfrom (gnc-localtime from-value)))
                   (and (equal? (tm:year bdto) (tm:year bdfrom))
                        (equal? (tm:mon bdfrom) 0)
                        (equal? (tm:mday bdfrom) 1)
@@ -613,23 +612,23 @@
                ;; Adjust dates so we get the final Estimated Tax
                ;; paymnent from the right year
                (from-est (if full-year?
-                             (let ((bdtm (gnc:timepair->date
-                                          (timespecCanonicalDayTime
+                             (let ((bdtm (gnc-localtime
+                                          (time64CanonicalDayTime
                                            from-value))))
                                (set-tm:mday bdtm 1) ; 01
                                (set-tm:mon bdtm 2) ; Mar
                                (set-tm:isdst bdtm -1)
-                               (cons (gnc-mktime bdtm) 0))
+                               (gnc-mktime bdtm))
                              from-value))
                (to-est (if full-year?
-                           (let* ((bdtm (gnc:timepair->date
-                                         (timespecCanonicalDayTime
+                           (let* ((bdtm (gnc-localtime
+                                         (time64CanonicalDayTime
                                           from-value))))
                              (set-tm:mday bdtm 28) ; 28
                              (set-tm:mon bdtm 1) ; Feb
                              (set-tm:year bdtm (+ (tm:year bdtm) 1))
                              (set-tm:isdst bdtm -1)
-                             (cons (gnc-mktime bdtm) 0))
+                             (gnc-mktime bdtm))
                            to-value)))
             (list from-est to-est full-year?))
           #f))
@@ -646,12 +645,12 @@
                      (+ 1 level)
                      level)))
         (map (lambda (spl) 
-               (let* ((date (gnc-transaction-get-date-posted
+               (let* ((date (xaccTransGetDate
                              (xaccSplitGetParent spl)))
                       (amount (xaccSplitGetAmount spl))
                       ;; TurboTax 1999 and 2000 ignore dates after Dec 31
                       (fudge-date (if (and full-year? 
-                                           (gnc:timepair-lt to-value date))
+                                           (< to-value date))
                                       to-value
                                       date)))
                  (if tax-mode?
@@ -765,13 +764,13 @@
             ;; Ignore
             '())))
 
-    (let ((from-date  (strftime "%d.%m.%Y" (gnc-localtime (car from-value))))
-          (to-date    (strftime "%d.%m.%Y" (gnc-localtime (car to-value))))
-	  (to-year    (strftime "%Y" (gnc-localtime (car to-value))))
+    (let ((from-date  (strftime "%d.%m.%Y" (gnc-localtime from-value)))
+          (to-date    (strftime "%d.%m.%Y" (gnc-localtime to-value)))
+	  (to-year    (strftime "%Y" (gnc-localtime to-value)))
           (today-date (strftime "%d.%m.%Y" 
                                 (gnc-localtime 
-                                 (car (timespecCanonicalDayTime
-                                       (cons (current-time) 0))))))
+                                 (time64CanonicalDayTime
+                                       (current-time)))))
 	  (tax-nr (or
                    (gnc:option-get-value book gnc:*tax-label* gnc:*tax-nr-label*)
 		   ""))

commit e3bd8f4ddbe1377d65494f19f183f6dbfe835906
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri Dec 15 23:26:57 2017 +0800

    TP->T64: gnucash/report/locale-specific/us/taxtxf.scm

diff --git a/gnucash/report/locale-specific/us/taxtxf.scm b/gnucash/report/locale-specific/us/taxtxf.scm
index ba2ad26..e5aeb30 100644
--- a/gnucash/report/locale-specific/us/taxtxf.scm
+++ b/gnucash/report/locale-specific/us/taxtxf.scm
@@ -120,31 +120,29 @@
 
 (define selected-accounts-sorted-by-form-line-acct (list))
 
-(define today (timespecCanonicalDayTime (cons (current-time) 0)))
+(define today (time64CanonicalDayTime (current-time)))
 
 (define bdtm
-  (let ((result (gnc:timepair->date today)))
+  (let ((result (gnc-localtime today)))
     (set-tm:mday result 16)             ; 16
     (set-tm:mon result 3)               ; Apr
     (set-tm:isdst result -1)
     result))
 
-(define tax-day (cons (gnc-mktime bdtm) 0))
+(define tax-day (gnc-mktime bdtm))
 
-(define after-tax-day (gnc:timepair-later tax-day today))
+(define after-tax-day (< tax-day today))
 
 (define (make-split-list account split-filter-pred)
   (filter split-filter-pred (xaccAccountGetSplitList account)))
 
 ;; returns a predicate that returns true only if a split is
 ;; between early-date and late-date
-(define (split-report-make-date-filter-predicate begin-date-tp end-date-tp)
+(define (split-report-make-date-filter-predicate begin-date-t64 end-date-t64)
   (lambda (split)
-    (let ((tp
-           (gnc-transaction-get-date-posted
-            (xaccSplitGetParent split))))
-      (and (gnc:timepair-ge-date tp begin-date-tp)
-           (gnc:timepair-le-date tp end-date-tp)))))
+    (let ((t64 (xaccTransGetDate (xaccSplitGetParent split))))
+      (and (>= t64 begin-date-t64)
+           (<= t64 end-date-t64)))))
 
 ;; This is nearly identical to, and could be shared with
 ;; display-report-list-item in report.scm. This adds warn-msg parameter
@@ -549,10 +547,10 @@
     (if (and txf?
              (not (gnc-numeric-zero-p account-value)))
         (let* ((date-str (if date
-                             (strftime "%m/%d/%Y" (gnc-localtime (car date)))
+                             (strftime "%m/%d/%Y" (gnc-localtime date))
                              #f))
                (x-date-str (if x-date
-                               (strftime "%m/%d/%Y" (gnc-localtime (car x-date)))
+                               (strftime "%m/%d/%Y" (gnc-localtime x-date))
                                #f))
                ;; Only formats 1,3,4,6 implemented now! Others are treated as 1.
                (format (get-acct-txf-info 'format type code))
@@ -725,7 +723,7 @@
                                           pricedb
                                           account-commodity
                                           USD-currency
-                                          (timespecCanonicalDayTime
+                                          (time64CanonicalDayTime
                                            lookup-date))))
                                           (if (gnc-commodity-equiv account-commodity (gnc-price-get-currency price))
                                               (set! price (gnc-price-invert price)))
@@ -746,7 +744,7 @@
                      ;; Use midday as the transaction time so it matches a price
                      ;; on the same day.  Otherwise it uses midnight which will
 	                 ;; likely match a price on the previous day
-                                        (timespecCanonicalDayTime lookup-date))
+                                        (time64CanonicalDayTime lookup-date))
                               )
                               (begin ;; otherwise set flag and set to zero
                                 (set! missing-pricedb-entry? #t)
@@ -822,7 +820,7 @@
                                (string-append
                                  " on "
                                  (strftime "%Y-%b-%d"
-                                    (gnc-localtime (car pricedb-lookup-price-time)))
+                                    (gnc-localtime pricedb-lookup-price-time))
                                  ")"
                                )
                                ""))
@@ -1231,7 +1229,7 @@
                                            account-commodity
                                            (if (equal? currency-conversion-date
                                                              'conv-to-tran-date)
-                                               (gnc:timepair-previous-day
+                                               (gnc:time64-previous-day
                                                                      from-value)
                                                to-value)
                                            account-commodity ;; force price lookup
@@ -1261,9 +1259,8 @@
                             ""
                             (string-append "Balance on "
                                          (strftime "%Y-%b-%d"
-                                            (gnc-localtime (car
-                                               (gnc:timepair-previous-day
-                                                                  from-value))))
+                                            (gnc-localtime (gnc:time64-previous-day
+                                                                  from-value)))
                                          (if (string=? curr-conv-note "")
                                              ":"
                                              (string-append  " " curr-conv-note)
@@ -1345,11 +1342,11 @@
       (set! output
         (map (lambda (split)
            (let* ((parent (xaccSplitGetParent split))
-                  (trans-date (gnc-transaction-get-date-posted parent))
+                  (trans-date (xaccTransGetDate parent))
                   ;; TurboTax 1999 and 2000 ignore dates after Dec 31
                   (fudge-date (if splits-period
                                   (if (and full-year?
-                                           (gnc:timepair-lt to-value trans-date))
+                                           (< to-value trans-date))
                                       to-value
                                       trans-date)
                                   trans-date))
@@ -1495,7 +1492,7 @@
                             (gnc:make-html-table-cell/markup
                                          "date-cell"
                                          (strftime "%Y-%b-%d"
-                                                 (gnc-localtime (car trans-date)))))
+                                                 (gnc-localtime trans-date))))
                        (gnc:html-table-set-style! num-table "table" 
                                           'attribute (list "border" "0")
                                           'attribute (list "cellspacing" "0")
@@ -1686,14 +1683,14 @@
                                     #f
                                     (if (txf-beg-bal-only? tax-code)
                                         (string-append "Balance on "
-                                           (strftime "%Y-%b-%d" (gnc-localtime (car
-                                                (gnc:timepair-previous-day
-                                                                  from-value))))
+                                           (strftime "%Y-%b-%d" (gnc-localtime 
+                                                (gnc:time64-previous-day
+                                                                  from-value)))
                                            " For "
                                         )
                                         (string-append "Balance on "
                                            (strftime "%Y-%b-%d"
-                                                     (gnc-localtime (car to-value)))
+                                                     (gnc-localtime to-value))
                                            " For "
                                         )
                                     )
@@ -2042,7 +2039,7 @@
   (gnc:report-starting reportname)
   (let* ((from-value (gnc:date-option-absolute-time
                       (get-option gnc:pagename-general "From")))
-         (to-value (gnc:timepair-end-day-time
+         (to-value (gnc:time64-end-day-time
                     (gnc:date-option-absolute-time
                      (get-option gnc:pagename-general "To"))))
          (alt-period (get-option gnc:pagename-general "Alternate Period"))
@@ -2087,8 +2084,8 @@
          (work-done 0)
 
          ;; Alternate dates are relative to from-date
-         (from-date (gnc:timepair->date from-value))
-         (from-value (gnc:timepair-start-day-time
+         (from-date (gnc-localtime from-value))
+         (from-value (gnc:time64-start-day-time
                       (let ((bdtm from-date))
                         (if (member alt-period
                                     '(last-year 1st-last 2nd-last
@@ -2118,9 +2115,9 @@
                               ((4th-est 4th-last) ; Oct 1
                                (set-tm:mon bdtm 9))))
                         (set-tm:isdst bdtm -1)
-                        (cons (gnc-mktime bdtm) 0))))
+                        (gnc-mktime bdtm))))
 
-         (to-value (gnc:timepair-end-day-time
+         (to-value (gnc:time64-end-day-time
                     (let ((bdtm from-date))
                       (if (member alt-period
                                   '(last-year 1st-last 2nd-last
@@ -2146,7 +2143,7 @@
                              (set-tm:mon bdtm 7))
                             ((4th-est 4th-last last-year) ; Dec 31
                              (set-tm:mon bdtm 11))
-                            (else (set! bdtm (gnc:timepair->date to-value))))
+                            (else (set! bdtm (gnc-localtime to-value))))
                           ;; Tax quaters equal Real quarters
                           (case alt-period
                             ((1st-est 1st-last) ; Mar 31
@@ -2160,9 +2157,9 @@
                             ((4th-est 4th-last last-year) ; Dec 31
                              (set-tm:mon bdtm 11))
                             (else
-                             (set! bdtm (gnc:timepair->date to-value)))))
+                             (set! bdtm (gnc-localtime to-value)))))
                       (set-tm:isdst bdtm -1)
-                      (cons (gnc-mktime bdtm) 0))))
+                      (gnc-mktime bdtm))))
 
          (form-line-acct-header-printed? #f)
          (form-schedule-header-printed? #f)
@@ -2179,8 +2176,8 @@
                (txf-special-date? (gnc:account-get-txf-code account)))
           (let*
               ((full-year?
-                (let ((bdto (gnc-localtime (car to-value)))
-                      (bdfrom (gnc-localtime (car from-value))))
+                (let ((bdto (gnc-localtime to-value))
+                      (bdfrom (gnc-localtime from-value)))
                   (and (equal? (tm:year bdto) (tm:year bdfrom))
                        (equal? (tm:mon bdfrom) 0)
                        (equal? (tm:mday bdfrom) 1)
@@ -2189,23 +2186,23 @@
               ;; Adjust dates so we get the final Estimated Tax
               ;; paymnent from the right year
                (from-est (if full-year?
-                             (let ((bdtm (gnc:timepair->date
-                                          (timespecCanonicalDayTime
+                             (let ((bdtm (gnc-localtime
+                                          (time64CanonicalDayTime
                                            from-value))))
                                (set-tm:mday bdtm 1) ; 01
                                (set-tm:mon bdtm 2) ; Mar
                                (set-tm:isdst bdtm -1)
-                               (cons (gnc-mktime bdtm) 0))
+                               (gnc-mktime bdtm))
                              from-value))
                (to-est (if full-year?
-                           (let* ((bdtm (gnc:timepair->date
-                                         (timespecCanonicalDayTime
+                           (let* ((bdtm (gnc-localtime
+                                         (time64CanonicalDayTime
                                           from-value))))
                              (set-tm:mday bdtm 28) ; 28
                              (set-tm:mon bdtm 1) ; Feb
                              (set-tm:year bdtm (+ (tm:year bdtm) 1))
                              (set-tm:isdst bdtm -1)
-                             (cons (gnc-mktime bdtm) 0))
+                             (gnc-mktime bdtm))
                            to-value)))
             (list from-est to-est full-year?))
           #f))
@@ -2253,7 +2250,7 @@
                                          (or (eq? account-type ACCT-TYPE-INCOME)
                                            (eq? account-type ACCT-TYPE-EXPENSE)))
                              (gnc:account-get-comm-balance-at-date account
-                                      (gnc:timepair-previous-day from-value) #f)
+                                      (gnc:time64-previous-day from-value) #f)
                              #f))
               (acct-end-bal-collector (if (not
                                          (or (eq? account-type ACCT-TYPE-INCOME)
@@ -2393,13 +2390,13 @@
           ) ;; end of let*
     )
 
-    (let ((from-date  (strftime "%Y-%b-%d" (gnc-localtime (car from-value))))
-          (to-date    (strftime "%Y-%b-%d" (gnc-localtime (car to-value))))
+    (let ((from-date  (strftime "%Y-%b-%d" (gnc-localtime from-value)))
+          (to-date    (strftime "%Y-%b-%d" (gnc-localtime to-value)))
           (today-date (strftime "D%m/%d/%Y"
                                 (gnc-localtime
-                                 (car (timespecCanonicalDayTime
-                                       (cons (current-time) 0))))))
-          (tax-year   (strftime "%Y" (gnc-localtime (car from-value))))
+                                 (time64CanonicalDayTime
+                                  (current-time)))))
+          (tax-year   (strftime "%Y" (gnc-localtime from-value)))
           (tax-entity-type (gnc-get-current-book-tax-type))
           (tax-entity-type-valid? #f)
           (prior-form-schedule "")

commit 896b9d976595695f2d8f0a4f80aeba8b9aeeac9c
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Dec 24 06:45:51 2017 +0800

    TP->T64: gnucash/report/standard-reports/income-gst-statement.scm

diff --git a/gnucash/report/standard-reports/income-gst-statement.scm b/gnucash/report/standard-reports/income-gst-statement.scm
index 8d327c8..b9b6e52 100644
--- a/gnucash/report/standard-reports/income-gst-statement.scm
+++ b/gnucash/report/standard-reports/income-gst-statement.scm
@@ -96,44 +96,44 @@ accounts must be of type ASSET for taxes paid on expenses, and type LIABILITY fo
 (define (split-same-corr-account-code-p a b)
   (= (xaccSplitCompareOtherAccountCodes a b) 0))
 
-(define (timepair-same-year tp-a tp-b)
-  (= (gnc:timepair-get-year tp-a)
-     (gnc:timepair-get-year tp-b)))
+(define (time64-same-year tp-a tp-b)
+  (= (gnc:time64-get-year tp-a)
+     (gnc:time64-get-year tp-b)))
 
-(define (timepair-same-quarter tp-a tp-b)
-  (and (timepair-same-year tp-a tp-b)
-       (= (gnc:timepair-get-quarter tp-a)
-          (gnc:timepair-get-quarter tp-b))))
+(define (time64-same-quarter tp-a tp-b)
+  (and (time64-same-year tp-a tp-b)
+       (= (gnc:time64-get-quarter tp-a)
+          (gnc:time64-get-quarter tp-b))))
 
-(define (timepair-same-month tp-a tp-b)
-  (and (timepair-same-year tp-a tp-b)
-       (= (gnc:timepair-get-month tp-a)
-          (gnc:timepair-get-month tp-b))))
+(define (time64-same-month tp-a tp-b)
+  (and (time64-same-year tp-a tp-b)
+       (= (gnc:time64-get-month tp-a)
+          (gnc:time64-get-month tp-b))))
 
-(define (timepair-same-week tp-a tp-b)
-  (and (timepair-same-year tp-a tp-b)
-       (= (gnc:timepair-get-week tp-a)
-          (gnc:timepair-get-week tp-b))))
+(define (time64-same-week tp-a tp-b)
+  (and (time64-same-year tp-a tp-b)
+       (= (gnc:time64-get-week tp-a)
+          (gnc:time64-get-week tp-b))))
 
 (define (split-same-week-p a b)
-  (let ((tp-a (gnc-transaction-get-date-posted (xaccSplitGetParent a)))
-        (tp-b (gnc-transaction-get-date-posted (xaccSplitGetParent b))))
-    (timepair-same-week tp-a tp-b)))
+  (let ((tp-a (xaccTransGetDate (xaccSplitGetParent a)))
+        (tp-b (xaccTransGetDate (xaccSplitGetParent b))))
+    (time64-same-week tp-a tp-b)))
 
 (define (split-same-month-p a b)
-  (let ((tp-a (gnc-transaction-get-date-posted (xaccSplitGetParent a)))
-        (tp-b (gnc-transaction-get-date-posted (xaccSplitGetParent b))))
-    (timepair-same-month tp-a tp-b)))
+  (let ((tp-a (xaccTransGetDate (xaccSplitGetParent a)))
+        (tp-b (xaccTransGetDate (xaccSplitGetParent b))))
+    (time64-same-month tp-a tp-b)))
 
 (define (split-same-quarter-p a b)
-  (let ((tp-a (gnc-transaction-get-date-posted (xaccSplitGetParent a)))
-        (tp-b (gnc-transaction-get-date-posted (xaccSplitGetParent b))))
-    (timepair-same-quarter tp-a tp-b)))
+  (let ((tp-a (xaccTransGetDate (xaccSplitGetParent a)))
+        (tp-b (xaccTransGetDate (xaccSplitGetParent b))))
+    (time64-same-quarter tp-a tp-b)))
 
 (define (split-same-year-p a b)
-  (let ((tp-a (gnc-transaction-get-date-posted (xaccSplitGetParent a)))
-        (tp-b (gnc-transaction-get-date-posted (xaccSplitGetParent b))))
-    (timepair-same-year tp-a tp-b)))
+  (let ((tp-a (xaccTransGetDate (xaccSplitGetParent a)))
+        (tp-b (xaccTransGetDate (xaccSplitGetParent b))))
+    (time64-same-year tp-a tp-b)))
 
 (define (set-last-row-style! table tag . rest)
   (let ((arg-list
@@ -197,29 +197,29 @@ accounts must be of type ASSET for taxes paid on expenses, and type LIABILITY fo
 
 (define (render-week-subheading split table width subheading-style column-vector)
   (add-subheading-row (gnc:date-get-week-year-string
-                       (gnc:timepair->date
-                        (gnc-transaction-get-date-posted
+                       (gnc-localtime
+                        (xaccTransGetDate
                          (xaccSplitGetParent split))))
                       table width subheading-style))
 
 (define (render-month-subheading split table width subheading-style column-vector)
   (add-subheading-row (gnc:date-get-month-year-string
-                       (gnc:timepair->date
-                        (gnc-transaction-get-date-posted
+                       (gnc-localtime
+                        (xaccTransGetDate
                          (xaccSplitGetParent split))))
                       table width subheading-style))
 
 (define (render-quarter-subheading split table width subheading-style column-vector)
   (add-subheading-row (gnc:date-get-quarter-year-string
-                       (gnc:timepair->date
-                        (gnc-transaction-get-date-posted
+                       (gnc-localtime
+                        (xaccTransGetDate
                          (xaccSplitGetParent split))))
                       table width subheading-style))
 
 (define (render-year-subheading split table width subheading-style column-vector)
   (add-subheading-row (gnc:date-get-year-string
-                       (gnc:timepair->date
-                        (gnc-transaction-get-date-posted
+                       (gnc-localtime
+                        (xaccTransGetDate
                          (xaccSplitGetParent split))))
                       table width subheading-style))
 
@@ -293,7 +293,7 @@ accounts must be of type ASSET for taxes paid on expenses, and type LIABILITY fo
 
 (define (render-week-subtotal
          table width split total-collector subtotal-style column-vector export?)
-  (let ((tm (gnc:timepair->date (gnc-transaction-get-date-posted
+  (let ((tm (gnc-localtime (xaccTransGetDate
                                  (xaccSplitGetParent split)))))
     (add-subtotal-row table width
                       (total-string (gnc:date-get-week-year-string tm))
@@ -301,7 +301,7 @@ accounts must be of type ASSET for taxes paid on expenses, and type LIABILITY fo
 
 (define (render-month-subtotal
          table width split total-collector subtotal-style column-vector export?)
-  (let ((tm (gnc:timepair->date (gnc-transaction-get-date-posted
+  (let ((tm (gnc-localtime (xaccTransGetDate
                                  (xaccSplitGetParent split)))))
     (add-subtotal-row table width
                       (total-string (gnc:date-get-month-year-string tm))
@@ -310,7 +310,7 @@ accounts must be of type ASSET for taxes paid on expenses, and type LIABILITY fo
 
 (define (render-quarter-subtotal
          table width split total-collector subtotal-style column-vector export?)
-  (let ((tm (gnc:timepair->date (gnc-transaction-get-date-posted
+  (let ((tm (gnc-localtime (xaccTransGetDate
                                  (xaccSplitGetParent split)))))
     (add-subtotal-row table width
                       (total-string (gnc:date-get-quarter-year-string tm))
@@ -318,7 +318,7 @@ accounts must be of type ASSET for taxes paid on expenses, and type LIABILITY fo
 
 (define (render-year-subtotal
          table width split total-collector subtotal-style column-vector export?)
-  (let ((tm (gnc:timepair->date (gnc-transaction-get-date-posted
+  (let ((tm (gnc-localtime (xaccTransGetDate
                                  (xaccSplitGetParent split)))))
     (add-subtotal-row table width
                       (total-string (strftime "%Y" tm))
@@ -518,7 +518,7 @@ accounts must be of type ASSET for taxes paid on expenses, and type LIABILITY fo
                               (opt-val gnc:pagename-general optname-currency)
                               currency))
          (sign-reverses? (opt-val gnc:pagename-display (N_ "Sign Reverses")))
-         (trans-date (gnc-transaction-get-date-posted parent))
+         (trans-date (xaccTransGetDate parent))
          (converted (lambda (num)
                       (gnc:exchange-by-pricedb-nearest
                        (gnc:make-gnc-monetary currency num)
@@ -540,15 +540,15 @@ accounts must be of type ASSET for taxes paid on expenses, and type LIABILITY fo
         (addto! row-contents
                 (if transaction-row?
                     (gnc:make-html-table-cell/markup "date-cell"
-                                                     (gnc-print-date (gnc-transaction-get-date-posted parent)))
+                                                     (qof-print-date (xaccTransGetDate parent)))
                     " ")))
     (if (used-reconciled-date column-vector)
         (addto! row-contents
                 (gnc:make-html-table-cell/markup "date-cell"
-                                                 (let ((date (gnc-split-get-date-reconciled split)))
-                                                   (if (equal? date (cons 0 0))
+                                                 (let ((date (xaccSplitGetDateReconciled split)))
+                                                   (if (zero? date)
                                                        " "
-                                                       (gnc-print-date date))))))
+                                                       (qof-print-date date))))))
     (if (used-num column-vector)
         (addto! row-contents
                 (if transaction-row?
@@ -1148,8 +1148,8 @@ for taxes paid on expenses, and type LIABILITY for taxes collected on sales.")
 
 
 (define (display-date-interval begin end)
-  (let ((begin-string (gnc-print-date begin))
-        (end-string (gnc-print-date end)))
+  (let ((begin-string (qof-print-date begin))
+        (end-string (qof-print-date end)))
     (sprintf #f (_ "From %s To %s") begin-string end-string)))
 
 (define (get-primary-subtotal-style options)
@@ -1616,10 +1616,10 @@ for taxes paid on expenses, and type LIABILITY for taxes collected on sales.")
          (accounts-sales (filter (lambda (acc) (eq? (xaccAccountGetType acc) ACCT-TYPE-INCOME)) c_account_1))
          (accounts-purchases (filter (lambda (acc) (eq? (xaccAccountGetType acc) ACCT-TYPE-EXPENSE)) c_account_1))
          (filter-mode (opt-val gnc:pagename-accounts "Filter Type"))
-         (begindate (gnc:timepair-start-day-time
+         (begindate (gnc:time64-start-day-time
                      (gnc:date-option-absolute-time
                       (opt-val gnc:pagename-general "Start Date"))))
-         (enddate (gnc:timepair-end-day-time
+         (enddate (gnc:time64-end-day-time
                    (gnc:date-option-absolute-time
                     (opt-val gnc:pagename-general "End Date"))))
          (transaction-matcher (opt-val gnc:pagename-general optname-transaction-matcher))
@@ -1648,7 +1648,7 @@ for taxes paid on expenses, and type LIABILITY for taxes collected on sales.")
           (xaccQueryAddAccountMatch query
                                     c_account_1
                                     QOF-GUID-MATCH-ANY QOF-QUERY-AND)
-          (xaccQueryAddDateMatchTS
+          (xaccQueryAddDateMatchTT
            query #t begindate #t enddate QOF-QUERY-AND)
           (qof-query-set-sort-order query
                                     (get-query-sortkey primary-key)

commit 03275a39a4d8dec8b7fb70f17cf49433e0b36887
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Dec 17 19:34:54 2017 +0800

    TP->T64: gnucash/report/standard-reports/test/test-generic-net-linechart.scm

diff --git a/gnucash/report/standard-reports/test/test-generic-net-linechart.scm b/gnucash/report/standard-reports/test/test-generic-net-linechart.scm
index 89825b7..4b12934 100644
--- a/gnucash/report/standard-reports/test/test-generic-net-linechart.scm
+++ b/gnucash/report/standard-reports/test/test-generic-net-linechart.scm
@@ -125,8 +125,8 @@
 	   (my-income-account (env-create-root-account env ACCT-TYPE-INCOME
 						       (gnc-default-report-currency)))
 	   (date-0 (gnc:get-start-this-month))
-	   (date-1 (gnc:timepair-next-day date-0))
-	   (date-2 (gnc:timepair-next-day date-1)))
+	   (date-1 (gnc:time64-next-day date-0))
+	   (date-2 (gnc:time64-next-day date-1)))
       (env-create-transaction env
 			       date-1
 			       my-income-account
@@ -185,8 +185,8 @@
 	   (my-income-account (env-create-root-account env ACCT-TYPE-INCOME
 						       (gnc-default-report-currency)))
 	   (date-0 (gnc:get-start-this-month))
-	   (date-1 (gnc:timepair-next-day date-0))
-	   (date-2 (gnc:timepair-next-day date-1)))
+	   (date-1 (gnc:time64-next-day date-0))
+	   (date-2 (gnc:time64-next-day date-1)))
       (env-create-transaction env date-1 my-income-account my-asset-account -1/1)
       (env-create-transaction env date-1 my-expense-account my-liability-account -1/1)
       (env-create-transaction env date-2 my-income-account my-asset-account -5/1)

commit b23cb7852b1dbc4f46380f4a521b6e4c92faaf92
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Dec 17 19:34:46 2017 +0800

    TP->T64: gnucash/report/standard-reports/test/test-generic-net-barchart.scm

diff --git a/gnucash/report/standard-reports/test/test-generic-net-barchart.scm b/gnucash/report/standard-reports/test/test-generic-net-barchart.scm
index 403eabe..c4a4bc2 100644
--- a/gnucash/report/standard-reports/test/test-generic-net-barchart.scm
+++ b/gnucash/report/standard-reports/test/test-generic-net-barchart.scm
@@ -129,8 +129,8 @@
 	   (my-income-account (env-create-root-account env ACCT-TYPE-INCOME
 						       (gnc-default-report-currency)))
 	   (date-0 (gnc:get-start-this-month))
-	   (date-1 (gnc:timepair-next-day date-0))
-	   (date-2 (gnc:timepair-next-day date-1)))
+	   (date-1 (gnc:time64-next-day date-0))
+	   (date-2 (gnc:time64-next-day date-1)))
       (env-create-transaction env
 			       date-1
 			       my-income-account
@@ -198,8 +198,8 @@
 	   (my-income-account (env-create-root-account env ACCT-TYPE-INCOME
 						       (gnc-default-report-currency)))
 	   (date-0 (gnc:get-start-this-month))
-	   (date-1 (gnc:timepair-next-day date-0))
-	   (date-2 (gnc:timepair-next-day date-1)))
+	   (date-1 (gnc:time64-next-day date-0))
+	   (date-2 (gnc:time64-next-day date-1)))
       (env-create-transaction env date-1 my-income-account my-asset-account -1/1)
       (env-create-transaction env date-1 my-expense-account my-liability-account -1/1)
       (env-create-transaction env date-2 my-income-account my-asset-account -5/1)
@@ -256,8 +256,8 @@
 	   (my-income-account (env-create-root-account env ACCT-TYPE-INCOME
 						       (gnc-default-report-currency)))
 	   (date-0 (gnc:get-start-this-month))
-	   (date-1 (gnc:timepair-next-day date-0))
-	   (date-2 (gnc:timepair-next-day date-1)))
+	   (date-1 (gnc:time64-next-day date-0))
+	   (date-2 (gnc:time64-next-day date-1)))
       (env-create-transaction env date-1 my-income-account my-asset-account -1/1)
       (env-create-transaction env date-1 my-expense-account my-liability-account -1/1)
       (env-create-transaction env date-2 my-income-account my-asset-account -5/1)
@@ -317,9 +317,9 @@
 	   (my-equity-account (env-create-root-account env ACCT-TYPE-EQUITY
 						       (gnc-default-report-currency)))
 	   (date-0 (gnc:get-start-this-month))
-	   (date-1 (gnc:timepair-next-day date-0))
-	   (date-2 (gnc:timepair-next-day date-1))
-	   (date-3 (gnc:timepair-next-day date-2)))
+	   (date-1 (gnc:time64-next-day date-0))
+	   (date-2 (gnc:time64-next-day date-1))
+	   (date-3 (gnc:time64-next-day date-2)))
 
       (env-create-transaction env date-1 my-income-account my-asset-account -1/1)
       (env-create-transaction env date-2 my-income-account my-asset-account -2/1)

commit 809936f0de0961cfbcaa2527643667292b6a62ec
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Dec 17 17:24:33 2017 +0800

    TP->T64: gnucash/report/standard-reports/test/test-cashflow-barchart.scm

diff --git a/gnucash/report/standard-reports/test/test-cashflow-barchart.scm b/gnucash/report/standard-reports/test/test-cashflow-barchart.scm
index 2b85f09..12cfd5b 100644
--- a/gnucash/report/standard-reports/test/test-cashflow-barchart.scm
+++ b/gnucash/report/standard-reports/test/test-cashflow-barchart.scm
@@ -73,8 +73,8 @@
            (expense-account (cdr (assoc "Expenses" account-alist)))
            (income-account (cdr (assoc "Income" account-alist)))
            (date-0 (gnc:get-start-this-month))
-           (date-1 (gnc:timepair-next-day date-0))
-           (date-2 (gnc:timepair-next-day date-1)))
+           (date-1 (gnc:time64-next-day date-0))
+           (date-2 (gnc:time64-next-day date-1)))
       (env-create-transaction env
                               date-1
                               bank-account
@@ -93,8 +93,8 @@
         (set-option report gnc:pagename-general "Price Source" 'pricedb-nearest)
         (set-option report gnc:pagename-general "Report's currency"  (gnc-default-report-currency))
         (set-option report gnc:pagename-accounts "Accounts" (list wallet-account bank-account))
-        (format #t "Create first transaction on ~a~%" (gnc-ctime (gnc:timepair->secs date-1)))
-        (format #t "Create second transaction on ~a~%" (gnc-ctime (gnc:timepair->secs date-2)))
+        (format #t "Create first transaction on ~a~%" (gnc-ctime date-1))
+        (format #t "Create second transaction on ~a~%" (gnc-ctime date-2))
         (let ((doc (renderer report)))
           (gnc:html-document-set-style-sheet! doc (gnc:report-stylesheet report))
           (let* ((result (gnc:html-document-render doc #f))
@@ -147,8 +147,8 @@
            (expense-account (cdr (assoc "Expenses" account-alist)))
            (income-account (cdr (assoc "Income" account-alist)))
            (date-0 (gnc:get-start-this-month))
-           (date-1 (gnc:timepair-next-day date-0))
-           (date-2 (gnc:timepair-next-day date-1)))
+           (date-1 (gnc:time64-next-day date-0))
+           (date-2 (gnc:time64-next-day date-1)))
       (env-create-transaction env
                               date-1
                               bank-account
@@ -230,8 +230,8 @@
            (expense-account (cdr (assoc "Expenses" account-alist)))
            (income-account (cdr (assoc "Income" account-alist)))
            (date-0 (gnc:get-start-this-month))
-           (date-1 (gnc:timepair-next-day date-0))
-           (date-2 (gnc:timepair-next-day date-1)))
+           (date-1 (gnc:time64-next-day date-0))
+           (date-2 (gnc:time64-next-day date-1)))
       (env-create-transaction env
                               date-1
                               bank-account

commit 46a2d18f10bc87562a1cecda9a47c9edc1d07095
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Dec 17 17:20:19 2017 +0800

    TP->T64: gnucash/report/standard-reports/test/test-cash-flow.scm

diff --git a/gnucash/report/standard-reports/test/test-cash-flow.scm b/gnucash/report/standard-reports/test/test-cash-flow.scm
index 45db741..8061376 100644
--- a/gnucash/report/standard-reports/test/test-cash-flow.scm
+++ b/gnucash/report/standard-reports/test/test-cash-flow.scm
@@ -18,11 +18,10 @@
 	      (list "Wallet"))
 	(list "Expenses" (list (cons 'type ACCT-TYPE-EXPENSE)))))
 
-(define (NDayDelta tp n)
+(define (NDayDelta t64 n)
   (let* ((day-secs (* 60 60 24 n)) ; n days in seconds is n times 60 sec/min * 60 min/h * 24 h/day
-         (new-secs (- (car tp) day-secs))
-         (new-tp (cons new-secs 0)))
-    new-tp))
+         (new-secs (- t64 day-secs)))
+    new-secs))
 
 (define (test-one-tx-in-cash-flow)
   (let* ((env (create-test-env))
@@ -31,15 +30,15 @@
 	 (wallet-account (cdr (assoc "Wallet" account-alist)))
 	 (expense-account (cdr (assoc "Expenses" account-alist)))
 	 (today (gnc-localtime (current-time)))
-         (to-date-tp (gnc-dmy2timespec-end (tm:mday today) (+ 1 (tm:mon today)) (+ 1900 (tm:year today))))
-         (from-date-tp (NDayDelta to-date-tp 1))
+         (to-date-t64 (gnc-dmy2time64-end (tm:mday today) (+ 1 (tm:mon today)) (+ 1900 (tm:year today))))
+         (from-date-t64 (NDayDelta to-date-t64 1))
 	 (exchange-fn (lambda (currency amount date) amount))
 	 (report-currency (gnc-default-report-currency))
 	 )
-    (env-create-transaction env to-date-tp bank-account expense-account 100/1)
+    (env-create-transaction env to-date-t64 bank-account expense-account 100/1)
     (let ((result (cash-flow-calc-money-in-out (list (cons 'accounts (list bank-account))
-						     (cons 'to-date-tp to-date-tp)
-						     (cons 'from-date-tp from-date-tp)
+						     (cons 'to-date-t64 to-date-t64)
+						     (cons 'from-date-t64 from-date-t64)
 						     (cons 'report-currency report-currency)
 						     (cons 'include-trading-accounts #f)
 						     (cons 'to-report-currency exchange-fn)))))
@@ -75,15 +74,15 @@
 	 (wallet-account (cdr (assoc "Wallet" account-alist)))
 	 (expense-account (cdr (assoc "Expenses" account-alist)))
 	 (today (gnc-localtime (current-time)))
-         (to-date-tp (gnc-dmy2timespec-end (tm:mday today) (+ 1 (tm:mon today)) (+ 1900 (tm:year today))))
-         (from-date-tp (NDayDelta to-date-tp 1))
+         (to-date-t64 (gnc-dmy2time64-end (tm:mday today) (+ 1 (tm:mon today)) (+ 1900 (tm:year today))))
+         (from-date-t64 (NDayDelta to-date-t64 1))
 	 (exchange-fn (lambda (currency amount date) amount))
 	 (report-currency (gnc-default-report-currency))
 	 )
-    (env-create-transaction env to-date-tp bank-account wallet-account 100/1)
+    (env-create-transaction env to-date-t64 bank-account wallet-account 100/1)
     (let ((result (cash-flow-calc-money-in-out (list (cons 'accounts (list wallet-account bank-account))
-						     (cons 'to-date-tp to-date-tp)
-						     (cons 'from-date-tp from-date-tp)
+						     (cons 'to-date-t64 to-date-t64)
+						     (cons 'from-date-t64 from-date-t64)
 						     (cons 'report-currency report-currency)
 						     (cons 'include-trading-accounts #f)
 						     (cons 'to-report-currency exchange-fn)))))
@@ -109,16 +108,16 @@
 	 (wallet-account (cdr (assoc "Wallet" account-alist)))
 	 (expense-account (cdr (assoc "Expenses" account-alist)))
 	 (today (gnc-localtime (current-time)))
-         (to-date-tp (gnc-dmy2timespec-end (tm:mday today) (+ 1 (tm:mon today)) (+ 1900 (tm:year today))))
-         (from-date-tp (NDayDelta to-date-tp 1))
+         (to-date-t64 (gnc-dmy2time64-end (tm:mday today) (+ 1 (tm:mon today)) (+ 1900 (tm:year today))))
+         (from-date-t64 (NDayDelta to-date-t64 1))
 	 (exchange-fn (lambda (currency amount date) amount))
 	 (report-currency (gnc-default-report-currency))
 	 )
-    (env-create-transaction env to-date-tp bank-account expense-account 100/1)
-    (env-create-transaction env to-date-tp expense-account bank-account 50/1)
+    (env-create-transaction env to-date-t64 bank-account expense-account 100/1)
+    (env-create-transaction env to-date-t64 expense-account bank-account 50/1)
     (let ((result (cash-flow-calc-money-in-out (list (cons 'accounts (list wallet-account bank-account))
-						     (cons 'to-date-tp to-date-tp)
-						     (cons 'from-date-tp from-date-tp)
+						     (cons 'to-date-t64 to-date-t64)
+						     (cons 'from-date-t64 from-date-t64)
 						     (cons 'report-currency report-currency)
 						     (cons 'include-trading-accounts #f)
 						     (cons 'to-report-currency exchange-fn)))))

commit 47544eafef71e4f6439cfe1231ddbd96ab93365c
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Dec 16 16:29:13 2017 +0800

    TP->T64: gnucash/report/standard-reports/cashflow-barchart.scm

diff --git a/gnucash/report/standard-reports/cashflow-barchart.scm b/gnucash/report/standard-reports/cashflow-barchart.scm
index 6c1d0fa..e4afa3a 100644
--- a/gnucash/report/standard-reports/cashflow-barchart.scm
+++ b/gnucash/report/standard-reports/cashflow-barchart.scm
@@ -163,18 +163,18 @@
                                       optname-report-currency))
          (price-source (get-option gnc:pagename-general
                                    optname-price-source))
-         (from-date-tp (gnc:timepair-start-day-time
-                        (gnc:date-option-absolute-time
-                         (get-option gnc:pagename-general
-                                     optname-from-date))))
-         (to-date-tp (gnc:timepair-end-day-time
-                      (gnc:date-option-absolute-time
-                       (get-option gnc:pagename-general
-                                   optname-to-date))))
+         (from-date-t64 (gnc:time64-start-day-time
+                         (gnc:date-option-absolute-time
+                          (get-option gnc:pagename-general
+                                      optname-from-date))))
+         (to-date-t64 (gnc:time64-end-day-time
+                       (gnc:date-option-absolute-time
+                        (get-option gnc:pagename-general
+                                    optname-to-date))))
 
          ;; calculate the exchange rates
          (exchange-fn (gnc:case-exchange-fn
-                       price-source report-currency to-date-tp))
+                       price-source report-currency to-date-t64))
 
          (interval (get-option gnc:pagename-general optname-stepsize))
          (show-in? (get-option gnc:pagename-display optname-show-in))
@@ -185,8 +185,8 @@
          (width (get-option gnc:pagename-display optname-plot-width))
 
          (dates-list (gnc:make-date-interval-list
-                      (gnc:timepair-start-day-time from-date-tp)
-                      (gnc:timepair-end-day-time to-date-tp)
+                      (gnc:time64-start-day-time from-date-t64)
+                      (gnc:time64-end-day-time to-date-t64)
                       (gnc:deltasym-to-delta interval)))
          (report-title (get-option gnc:pagename-general
                                    gnc:optname-reportname))
@@ -216,10 +216,10 @@
                ;; nearest available exchange rate if that is what is specified
                (time-exchange-fn (gnc:case-exchange-time-fn
                                   price-source report-currency
-                                  commodity-list to-date-tp
+                                  commodity-list to-date-t64
                                   0 0))
                (date-string-list (map (lambda (date-list-item)       ; date-list-item is (start . end)
-                                        (gnc-print-date (car date-list-item)))
+                                        (qof-print-date (car date-list-item)))
                                       dates-list))
                (results-by-date '())
                (in-list '())
@@ -270,8 +270,8 @@
              (set! work-done (+ 1 work-done))
              (gnc:report-percent-done (* 80 (/ work-done work-to-do)))
              (let* ((settings (list (cons 'accounts accounts)
-                                    (cons 'to-date-tp (second date-pair))
-                                    (cons 'from-date-tp (first date-pair))
+                                    (cons 'to-date-t64 (second date-pair))
+                                    (cons 'from-date-t64 (first date-pair))
                                     (cons 'report-currency report-currency)
                                     (cons 'include-trading-accounts include-trading-accounts)
                                     (cons 'to-report-currency to-report-currency)))
@@ -311,8 +311,8 @@
           (gnc:html-barchart-set-subtitle!
            chart (sprintf #f
                           (_ "%s to %s")
-                          (gnc-print-date from-date-tp)
-                          (gnc-print-date to-date-tp)))
+                          (qof-print-date from-date-t64)
+                          (qof-print-date to-date-t64)))
           (gnc:html-barchart-set-width! chart width)
           (gnc:html-barchart-set-height! chart height)
           (gnc:html-barchart-set-row-labels! chart date-string-list)
@@ -398,8 +398,8 @@
 ;; function to add inflow and outflow of money
 (define (cashflow-barchart-calc-money-in-out settings)
   (let* ((accounts (cdr (assq 'accounts settings)))
-         (to-date-tp (cdr (assq 'to-date-tp settings)))
-         (from-date-tp (cdr (assq 'from-date-tp settings)))
+         (to-date-t64 (cdr (assq 'to-date-t64 settings)))
+         (from-date-t64 (cdr (assq 'from-date-t64 settings)))
          (report-currency (cdr (assq 'report-currency settings)))
          (include-trading-accounts (cdr (assq 'include-trading-accounts settings)))
          (to-report-currency (cdr (assq 'to-report-currency settings)))
@@ -414,7 +414,7 @@
          (money-out-hash (make-hash-table))
          (money-out-collector (gnc:make-commodity-collector))
 
-         (all-splits (gnc:account-get-trans-type-splits-interval accounts '() from-date-tp to-date-tp))
+         (all-splits (gnc:account-get-trans-type-splits-interval accounts '() from-date-t64 to-date-t64))
          (splits-seen-table (make-hash-table)))
 
     (define (split-seen? split)
@@ -425,8 +425,8 @@
 
     (define (work-per-split split)
       (let ((parent (xaccSplitGetParent split)))
-        (if (and (gnc:timepair-le (gnc-transaction-get-date-posted parent) to-date-tp)
-                 (gnc:timepair-ge (gnc-transaction-get-date-posted parent) from-date-tp))
+        (if (and (<= (xaccTransGetDate parent) to-date-t64)
+                 (>= (xaccTransGetDate parent) from-date-t64))
             (let* ((parent-description (xaccTransGetDescription parent))
                    (parent-currency (xaccTransGetCurrency parent)))
                                         ;(gnc:debug parent-description
@@ -469,7 +469,7 @@
                                        )
                                    (let ((s-report-value (to-report-currency parent-currency
                                                                              (gnc-numeric-neg s-value)
-                                                                             (gnc-transaction-get-date-posted
+                                                                             (xaccTransGetDate
                                                                               parent))))
                                      (money-in-collector 'add report-currency s-report-value)
                                      (s-account-in-collector 'add report-currency s-report-value))
@@ -489,7 +489,7 @@
                                        )
                                    (let ((s-report-value (to-report-currency parent-currency
                                                                              s-value
-                                                                             (gnc-transaction-get-date-posted
+                                                                             (xaccTransGetDate
                                                                               parent))))
                                      (money-out-collector 'add report-currency s-report-value)
                                      (s-account-out-collector 'add report-currency s-report-value))

commit 1adbe4d3297cd8068fb424618adf414a792da0c6
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Dec 16 16:09:59 2017 +0800

    TP->T64: gnucash/report/standard-reports/category-barchart.scm

diff --git a/gnucash/report/standard-reports/category-barchart.scm b/gnucash/report/standard-reports/category-barchart.scm
index cd04b91..df473af 100644
--- a/gnucash/report/standard-reports/category-barchart.scm
+++ b/gnucash/report/standard-reports/category-barchart.scm
@@ -237,14 +237,14 @@ developing over time"))
       (gnc:report-options report-obj) section name)))
   
   (gnc:report-starting reportname)
-  (let* ((to-date-tp (gnc:timepair-end-day-time
-                     (gnc:date-option-absolute-time
-                      (get-option gnc:pagename-general 
-                                  optname-to-date))))
-        (from-date-tp (gnc:timepair-start-day-time 
+  (let* ((to-date-t64 (gnc:time64-end-day-time
                        (gnc:date-option-absolute-time
                         (get-option gnc:pagename-general 
-                                    optname-from-date))))
+                                    optname-to-date))))
+        (from-date-t64 (gnc:time64-start-day-time 
+                        (gnc:date-option-absolute-time
+                         (get-option gnc:pagename-general 
+                                     optname-from-date))))
         (interval (get-option gnc:pagename-general optname-stepsize))
         (report-currency (get-option gnc:pagename-general
                                      optname-report-currency))
@@ -303,14 +303,14 @@ developing over time"))
                  (if averaging-fraction-func
                      ;; Calculate the divisor of the amounts so that an
                      ;; average is shown. Multiplier factor is a gnc-numeric
-                     (let* ((start-frac-avg (averaging-fraction-func (gnc:timepair->secs from-date-tp)))
-                             (end-frac-avg (averaging-fraction-func (+ 1 (gnc:timepair->secs to-date-tp))))
+                     (let* ((start-frac-avg (averaging-fraction-func from-date-t64))
+                             (end-frac-avg (averaging-fraction-func (+ 1 to-date-t64)))
                              (diff-avg (- end-frac-avg start-frac-avg))
                              (diff-avg-numeric (/
                                                 (inexact->exact (round (* diff-avg 1000000))) ; 6 decimals precision
                                                 1000000))
-                             (start-frac-int (interval-fraction-func (gnc:timepair->secs from-date-tp)))
-                             (end-frac-int (interval-fraction-func (+ 1 (gnc:timepair->secs to-date-tp))))
+                             (start-frac-int (interval-fraction-func from-date-t64))
+                             (end-frac-int (interval-fraction-func (+ 1 to-date-t64)))
                              (diff-int (- end-frac-int start-frac-int))
                              (diff-int-numeric (/
                                                 (inexact->exact diff-int) 1))
@@ -332,12 +332,12 @@ developing over time"))
                ;; This is the list of date intervals to calculate.
                (dates-list (if do-intervals?
                                (gnc:make-date-interval-list
-                                (gnc:timepair-start-day-time from-date-tp) 
-                                (gnc:timepair-end-day-time to-date-tp)
+                                (gnc:time64-start-day-time from-date-t64) 
+                                (gnc:time64-end-day-time to-date-t64)
                                 (gnc:deltasym-to-delta interval))
                                (gnc:make-date-list
-                                (gnc:timepair-end-day-time from-date-tp) 
-                                (gnc:timepair-end-day-time to-date-tp)
+                                (gnc:time64-end-day-time from-date-t64) 
+                                (gnc:time64-end-day-time to-date-t64)
                                 (gnc:deltasym-to-delta interval))))
                ;; Here the date strings for the x-axis labels are
                ;; created.
@@ -349,7 +349,7 @@ developing over time"))
 
           (define (datelist->stringlist dates-list)
             (map (lambda (date-list-item)
-                         (gnc-print-date
+                         (qof-print-date
                           (if do-intervals?
                               (car date-list-item)
                               date-list-item)))
@@ -361,7 +361,7 @@ developing over time"))
           ;; instead of division to avoid division-by-zero issues) in case
           ;; the user wants to see the amounts averaged over some value.
           (define (collector->monetary c date)
-            (if (not (gnc:timepair? date))
+            (if (not (number? date))
                 (throw 'wrong))
             (gnc:make-gnc-monetary
              report-currency
@@ -474,7 +474,7 @@ developing over time"))
                                 report-currency))
 	  (set! exchange-fn (gnc:case-exchange-time-fn 
                              price-source report-currency 
-                             commodity-list to-date-tp
+                             commodity-list to-date-t64
 			     5 15))
 
           ;; Sort the account list according to the account code field.
@@ -530,8 +530,8 @@ developing over time"))
                              (if do-intervals?
                                  (_ "%s to %s")
                                  (_ "Balances %s to %s"))
-                             (jqplot-escape-string (gnc-print-date from-date-tp))
-                             (jqplot-escape-string (gnc-print-date to-date-tp))))
+                             (jqplot-escape-string (qof-print-date from-date-t64))
+                             (jqplot-escape-string (qof-print-date to-date-t64))))
 
                  (gnc:html-barchart-set-width! chart width)
                  (gnc:html-barchart-set-height! chart height)
@@ -556,8 +556,8 @@ developing over time"))
                              (if do-intervals?
                                  (_ "%s to %s")
                                  (_ "Balances %s to %s"))
-                             (jqplot-escape-string (gnc-print-date from-date-tp))
-                             (jqplot-escape-string (gnc-print-date to-date-tp))))
+                             (jqplot-escape-string (qof-print-date from-date-t64))
+                             (jqplot-escape-string (qof-print-date to-date-t64))))
 
                  (gnc:html-linechart-set-width! chart width)
                  (gnc:html-linechart-set-height! chart height)

commit 3adec363fa87b8e06d3500ee45f2b140d6b543ca
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Dec 16 13:39:20 2017 +0800

    TP->T64: gnucash/report/standard-reports/net-barchart.scm

diff --git a/gnucash/report/standard-reports/net-barchart.scm b/gnucash/report/standard-reports/net-barchart.scm
index ef1532b..9181cfe 100644
--- a/gnucash/report/standard-reports/net-barchart.scm
+++ b/gnucash/report/standard-reports/net-barchart.scm
@@ -156,11 +156,11 @@
      (gnc:lookup-option (gnc:report-options report-obj) section name)))
 
   (gnc:report-starting reportname)
-  (let* ((to-date-tp (gnc:timepair-end-day-time
+  (let* ((to-date-t64 (gnc:time64-end-day-time
                       (gnc:date-option-absolute-time
                        (get-option gnc:pagename-general
 				   optname-to-date))))
-         (from-date-tp (gnc:timepair-start-day-time
+         (from-date-t64 (gnc:time64-start-day-time
                         (gnc:date-option-absolute-time
                          (get-option gnc:pagename-general
 				     optname-from-date))))
@@ -184,11 +184,14 @@
          (commodity-list #f)
          (exchange-fn #f)
 
-         (dates-list ((if inc-exp? gnc:make-date-interval-list
+         (dates-list ((if inc-exp?
+                          gnc:make-date-interval-list
                           gnc:make-date-list)
-                      ((if inc-exp? gnc:timepair-start-day-time
-                           gnc:timepair-end-day-time) from-date-tp)
-                      (gnc:timepair-end-day-time to-date-tp)
+                      ((if inc-exp?
+                           gnc:time64-start-day-time
+                           gnc:time64-end-day-time)
+                       from-date-t64)
+                      (gnc:time64-end-day-time to-date-t64)
                       (gnc:deltasym-to-delta interval)))
 	 (report-title (get-option gnc:pagename-general
                                   gnc:optname-reportname))
@@ -207,7 +210,7 @@
     ;; This exchanges the commodity-collector 'c' to one single
     ;; 'report-currency' according to the exchange-fn. Returns a gnc:monetary
     (define (collector->monetary c date)
-      (if (not (gnc:timepair? date))
+      (if (not (number? date))
 	  (throw 'wrong))
       (gnc:sum-collector-commodity
        c report-currency
@@ -261,7 +264,7 @@
     (gnc:report-percent-done 10)
     (set! exchange-fn (gnc:case-exchange-time-fn
                        price-source report-currency
-                       commodity-list to-date-tp
+                       commodity-list to-date-t64
 		       10 40))
     (gnc:report-percent-done 50)
 
@@ -274,9 +277,9 @@
             (date-string-list (map
                                (if inc-exp?
                                    (lambda (date-list-item)
-                                     (gnc-print-date
+                                     (qof-print-date
                                       (car date-list-item)))
-                                   gnc-print-date)
+                                   qof-print-date)
                                dates-list)))
        (let* ((the-acount-destination-alist
 	       (if inc-exp?
@@ -332,8 +335,8 @@
        (gnc:html-barchart-set-subtitle!
         chart (sprintf #f
                        (_ "%s to %s")
-                       (jqplot-escape-string (gnc-print-date from-date-tp))
-                       (jqplot-escape-string (gnc-print-date to-date-tp))))
+                       (jqplot-escape-string (qof-print-date from-date-t64))
+                       (jqplot-escape-string (qof-print-date to-date-t64))))
        (gnc:html-barchart-set-width! chart width)
        (gnc:html-barchart-set-height! chart height)
        (gnc:html-barchart-set-row-labels! chart date-string-list)

commit 0a96af20e2b65a114a9b2afa22e3fde8ae4ab89d
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue Dec 19 23:16:44 2017 +0800

    TP->T64: gnucash/report/standard-reports/net-linechart.scm

diff --git a/gnucash/report/standard-reports/net-linechart.scm b/gnucash/report/standard-reports/net-linechart.scm
index 13a37bf..6a1cea1 100644
--- a/gnucash/report/standard-reports/net-linechart.scm
+++ b/gnucash/report/standard-reports/net-linechart.scm
@@ -188,11 +188,11 @@
      (gnc:lookup-option (gnc:report-options report-obj) section name)))
 
   (gnc:report-starting reportname)
-  (let* ((to-date-tp (gnc:timepair-end-day-time
+  (let* ((to-date-t64 (gnc:time64-end-day-time
                       (gnc:date-option-absolute-time
                        (get-option gnc:pagename-general
 				   optname-to-date))))
-         (from-date-tp (gnc:timepair-start-day-time
+         (from-date-t64 (gnc:time64-start-day-time
                         (gnc:date-option-absolute-time
                          (get-option gnc:pagename-general
 				     optname-from-date))))
@@ -221,11 +221,13 @@
          (commodity-list #f)
          (exchange-fn #f)
 
-         (dates-list ((if inc-exp? gnc:make-date-interval-list
+         (dates-list ((if inc-exp?
+                          gnc:make-date-interval-list
                           gnc:make-date-list)
-                      ((if inc-exp? gnc:timepair-start-day-time
-                           gnc:timepair-end-day-time) from-date-tp)
-                      (gnc:timepair-end-day-time to-date-tp)
+                      ((if inc-exp?
+                           gnc:time64-start-day-time
+                           gnc:time64-end-day-time) from-date-t64)
+                      (gnc:time64-end-day-time to-date-t64)
                       (gnc:deltasym-to-delta interval)))
 	 (report-title (get-option gnc:pagename-general
                                   gnc:optname-reportname))
@@ -244,7 +246,7 @@
     ;; This exchanges the commodity-collector 'c' to one single
     ;; 'report-currency' according to the exchange-fn. Returns a gnc:monetary
     (define (collector->monetary c date)
-      (if (not (gnc:timepair? date))
+      (if (not (number? date))
 	  (throw 'wrong))
       (gnc:sum-collector-commodity
        c report-currency
@@ -298,7 +300,7 @@
     (gnc:report-percent-done 10)
     (set! exchange-fn (gnc:case-exchange-time-fn
                        price-source report-currency
-                       commodity-list to-date-tp
+                       commodity-list to-date-t64
 		       10 40))
     (gnc:report-percent-done 50)
 
@@ -316,7 +318,7 @@
 
        (define (datelist->stringlist dates-list)
          (map (lambda (date-list-item)
-                      (gnc-print-date
+                      (qof-print-date
                        (if inc-exp?
                            (car date-list-item)
                            date-list-item)))
@@ -376,8 +378,8 @@
        (gnc:html-linechart-set-subtitle!
         chart (sprintf #f
                        (_ "%s to %s")
-                       (gnc-print-date from-date-tp)
-                       (gnc-print-date to-date-tp)))
+                       (qof-print-date from-date-t64)
+                       (qof-print-date to-date-t64)))
        (gnc:html-linechart-set-width! chart width)
        (gnc:html-linechart-set-height! chart height)
 

commit 0aa69a5f540aba1d8c88728b16502fdc6977eee4
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Dec 30 18:41:12 2017 +1100

    TP->T64: gnucash/report/standard-reports/transaction.scm

diff --git a/gnucash/report/standard-reports/transaction.scm b/gnucash/report/standard-reports/transaction.scm
index 0ee0df3..ae5c1c9 100644
--- a/gnucash/report/standard-reports/transaction.scm
+++ b/gnucash/report/standard-reports/transaction.scm
@@ -1639,10 +1639,10 @@ tags within description, notes or memo. ")
                        c_account_0))
          (c_account_2 (opt-val gnc:pagename-accounts optname-filterby))
          (filter-mode (opt-val gnc:pagename-accounts optname-filtertype))
-         (begindate (gnc:timepair-start-day-time
+         (begindate (gnc:time64-start-day-time
                      (gnc:date-option-absolute-time
                       (opt-val gnc:pagename-general optname-startdate))))
-         (enddate (gnc:timepair-end-day-time
+         (enddate (gnc:time64-end-day-time
                    (gnc:date-option-absolute-time
                     (opt-val gnc:pagename-general optname-enddate))))
          (transaction-matcher (opt-val pagename-filter optname-transaction-matcher))
@@ -1821,7 +1821,7 @@ tags within description, notes or memo. ")
 
           (qof-query-set-book query (gnc-get-current-book))
           (xaccQueryAddAccountMatch query c_account_1 QOF-GUID-MATCH-ANY QOF-QUERY-AND)
-          (xaccQueryAddDateMatchTS query #t begindate #t enddate QOF-QUERY-AND)
+          (xaccQueryAddDateMatchTT query #t begindate #t enddate QOF-QUERY-AND)
           (case void-status
             ((non-void-only) (gnc:query-set-match-non-voids-only! query (gnc-get-current-book)))
             ((void-only)     (gnc:query-set-match-voids-only! query (gnc-get-current-book)))
@@ -1894,8 +1894,8 @@ tags within description, notes or memo. ")
                   (gnc:html-markup-h3
                    (sprintf #f
                             (_ "From %s to %s")
-                            (gnc-print-date begindate)
-                            (gnc-print-date enddate)))))
+                            (qof-print-date begindate)
+                            (qof-print-date enddate)))))
 
                 (if (member 'match infobox-display)
                     (gnc:html-document-add-object!

commit 1181f7fee71fe1087c3bff30f282197894d28c17
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri Dec 15 19:24:24 2017 +0800

    TP->T64: gnucash/report/standard-reports/budget-income-statement.scm

diff --git a/gnucash/report/standard-reports/budget-income-statement.scm b/gnucash/report/standard-reports/budget-income-statement.scm
index 0dc9a4fb..13b0869 100644
--- a/gnucash/report/standard-reports/budget-income-statement.scm
+++ b/gnucash/report/standard-reports/budget-income-statement.scm
@@ -350,7 +350,7 @@
            (if use-budget-period-range? (- user-budget-period-start 1) #f))
          (period-end
            (if use-budget-period-range? user-budget-period-end #f))
-         (date-tp
+         (date-t64
            (if budget-valid?
              (gnc-budget-get-period-start-date
                budget
@@ -416,7 +416,7 @@
 			 depth-limit))
          ;; exchange rates calculation parameters
 	 (exchange-fn
-	  (gnc:case-exchange-fn price-source report-commodity date-tp))
+	  (gnc:case-exchange-fn price-source report-commodity date-t64))
 	 )
     
     ;; Wrapper to call gnc:html-table-add-labeled-amount-line!

commit a7eb1bcc7722a9d63928249b919a09f52e7bf1e3
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri Dec 15 19:22:24 2017 +0800

    TP->T64: gnucash/report/standard-reports/budget-balance-sheet.scm

diff --git a/gnucash/report/standard-reports/budget-balance-sheet.scm b/gnucash/report/standard-reports/budget-balance-sheet.scm
index 00ec823..1b8d042 100644
--- a/gnucash/report/standard-reports/budget-balance-sheet.scm
+++ b/gnucash/report/standard-reports/budget-balance-sheet.scm
@@ -310,7 +310,7 @@
 	 (company-name (get-option gnc:pagename-general optname-party-name))
          (budget (get-option gnc:pagename-general optname-budget))
          (budget-valid? (and budget (not (null? budget))))
-         (date-tp (if budget-valid? (gnc:budget-get-start-date budget) #f))
+         (date-t64 (if budget-valid? (gnc:budget-get-start-date budget) #f))
          (report-form? (get-option gnc:pagename-general
                                optname-report-form))
          (accounts (get-option gnc:pagename-accounts
@@ -379,7 +379,7 @@
 
          ;; exchange rates calculation parameters
 	 (exchange-fn
-	  (gnc:case-exchange-fn price-source report-commodity date-tp))
+	  (gnc:case-exchange-fn price-source report-commodity date-t64))
 	 )
     
     ;; Wrapper to call gnc:html-table-add-labeled-amount-line!
@@ -652,7 +652,7 @@
             (
               (get-total-value-fn
                 (lambda (account)
-                  (gnc:account-get-comm-value-at-date account date-tp #f)))
+                  (gnc:account-get-comm-value-at-date account date-t64 #f)))
               (asset-basis
                 (gnc:accounts-get-comm-total-assets
                   asset-accounts get-total-value-fn))

commit f2e1b9fb48495d871188c9b14d169795b84d8235
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri Dec 15 19:12:53 2017 +0800

    TP->T64: gnucash/report/standard-reports/budget-flow.scm

diff --git a/gnucash/report/standard-reports/budget-flow.scm b/gnucash/report/standard-reports/budget-flow.scm
index fab3b28..4bf0cf3 100644
--- a/gnucash/report/standard-reports/budget-flow.scm
+++ b/gnucash/report/standard-reports/budget-flow.scm
@@ -319,7 +319,7 @@
         (gnc:html-document-set-title!
           doc (sprintf #f (_ "%s: %s - %s")
             report-name (gnc-budget-get-name budget)
-            (gnc-print-date (gnc-budget-get-period-start-date budget (- period 1)))))
+            (qof-print-date (gnc-budget-get-period-start-date budget (- period 1)))))
 
         ;; Display accounts and totals
         (set! accounts-totals (gnc:html-table-add-budget-types! html-table split-up-accounts budget period exchange-fn report-currency))

commit 811d4e5718479e60b82898f6ea3c50c0c0af1997
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri Dec 15 19:12:06 2017 +0800

    TP->T64: gnucash/report/standard-reports/budget-barchart.scm

diff --git a/gnucash/report/standard-reports/budget-barchart.scm b/gnucash/report/standard-reports/budget-barchart.scm
index 33cadc9..105da0a 100644
--- a/gnucash/report/standard-reports/budget-barchart.scm
+++ b/gnucash/report/standard-reports/budget-barchart.scm
@@ -141,11 +141,9 @@
 ;;
 ;; Create bar and and values
 ;;
-(define (gnc:chart-create-budget-actual budget acct running-sum chart-type width height from-tp to-tp)
+(define (gnc:chart-create-budget-actual budget acct running-sum chart-type width height report-start-time report-end-time)
   (let* (
           (chart #f)
-          (report-start-time (car from-tp))
-          (report-end-time (car to-tp))
         )
 
     (if (eqv? chart-type 'bars)
@@ -183,7 +181,6 @@
         (bgt-sum 0)
         (act-sum 0)
         (date (gnc-budget-get-period-start-date budget period))
-        (period-start-time (car date))
         (bgt-vals '())
         (act-vals '())
         (date-iso-string-list '())
@@ -206,7 +203,7 @@
                 (gnc-budget-get-account-period-actual-value budget acct period))))
           )
         )
-        (if (<= report-start-time period-start-time)
+        (if (<= report-start-time date)
 	  ;; within reporting period, update the display lists
           (begin
             (if (not running-sum)
@@ -221,14 +218,13 @@
             )
             (set! bgt-vals (append bgt-vals (list bgt-sum)))
             (set! act-vals (append act-vals (list act-sum)))
-            (set! date-iso-string-list (append date-iso-string-list (list (gnc-print-date date))))
+            (set! date-iso-string-list (append date-iso-string-list (list (qof-print-date date))))
           )
         )
         ;; prepare data for next loop repetition
         (set! period (+ period 1))
         (set! date (gnc-budget-get-period-start-date budget period))
-        (set! period-start-time (car date))
-        (if (< report-end-time period-start-time)
+        (if (< report-end-time date)
           (set! period num-periods) ;; reporting period has ended, break the loop
         )
       )
@@ -319,10 +315,10 @@
       (report-title (get-option gnc:pagename-general
         gnc:optname-reportname))
       (document (gnc:make-html-document))
-      (from-date-tp (gnc:timepair-start-day-time
+      (from-date-t64 (gnc:time64-start-day-time
                       (gnc:date-option-absolute-time
                         (get-option gnc:pagename-general optname-from-date))))
-      (to-date-tp (gnc:timepair-end-day-time
+      (to-date-t64 (gnc:time64-end-day-time
                     (gnc:date-option-absolute-time
                       (get-option gnc:pagename-general optname-to-date))))
     )
@@ -357,7 +353,7 @@
                 )
               (gnc:html-document-add-object!
                 document
-                (gnc:chart-create-budget-actual budget acct running-sum chart-type width height from-date-tp to-date-tp)
+                (gnc:chart-create-budget-actual budget acct running-sum chart-type width height from-date-t64 to-date-t64)
               )
             )
           )

commit db316c2d16ad2441e66819c2942bbae0b965ee52
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri Dec 15 18:47:42 2017 +0800

    TP->T64: gnucash/report/standard-reports/budget.scm

diff --git a/gnucash/report/standard-reports/budget.scm b/gnucash/report/standard-reports/budget.scm
index e061b0d..23ae0d0 100644
--- a/gnucash/report/standard-reports/budget.scm
+++ b/gnucash/report/standard-reports/budget.scm
@@ -553,7 +553,7 @@
                              (let* (
                                     (col-info (car col-list))
                                     (tc #f)
-                                    (period-to-date-string (lambda (p) (gnc-print-date (gnc-budget-get-period-start-date budget p))))
+                                    (period-to-date-string (lambda (p) (qof-print-date (gnc-budget-get-period-start-date budget p))))
                                    )
                                    (cond
                                     ((equal? col-info 'total)
@@ -631,8 +631,8 @@
             (let* ((now (current-time))
                   (total-periods (gnc-budget-get-num-periods budget) )
                   (last-period (- total-periods 1))
-                  (period-start (lambda (x) (car (gnc-budget-get-period-start-date budget x))))
-                  (period-end (lambda (x) (car (gnc-budget-get-period-end-date budget x))))
+                  (period-start (lambda (x) (gnc-budget-get-period-start-date budget x)))
+                  (period-end (lambda (x) (gnc-budget-get-period-end-date budget x)))
                  )
                 (cond ((< now (period-start 0)) 1)
                       ((> now (period-end last-period)) total-periods)

commit 98ef625adab0bf02f987e09d36af5e895f220ca3
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Nov 25 00:40:43 2017 +0800

    TP->T64: gnucash/report/standard-reports/register.scm

diff --git a/gnucash/report/standard-reports/register.scm b/gnucash/report/standard-reports/register.scm
index 6522f6e..23c61a7 100644
--- a/gnucash/report/standard-reports/register.scm
+++ b/gnucash/report/standard-reports/register.scm
@@ -203,8 +203,8 @@
                 (if transaction-info?
                     (gnc:make-html-table-cell/markup
 					    "date-cell"
-                        (gnc-print-date
-                             (gnc-transaction-get-date-posted parent)))
+                        (qof-print-date
+                             (xaccTransGetDate parent)))
                         " ")))
     (if (num-col column-vector)
         (addto! row-contents
@@ -810,7 +810,7 @@
      (list
       (string-append
        (_ "Date") ": "
-       (string-expand (gnc-print-date (cons (current-time) 0))
+       (string-expand (qof-print-date (current-time))
                       #\space " "))
       (make-client-table address)))
     (set-last-row-style!

commit 1f61a6aaf4bbbec7ea67bf7ccba4f4c3539ff203
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Nov 25 00:33:04 2017 +0800

    TP->T64: gnucash/report/standard-reports/equity-statement.scm

diff --git a/gnucash/report/standard-reports/equity-statement.scm b/gnucash/report/standard-reports/equity-statement.scm
index c5896b1..6c514fa 100644
--- a/gnucash/report/standard-reports/equity-statement.scm
+++ b/gnucash/report/standard-reports/equity-statement.scm
@@ -207,9 +207,9 @@
          (start-date-printable (gnc:date-option-absolute-time
 				(get-option gnc:pagename-general
 					    optname-start-date)))
-         (start-date-tp (gnc:timepair-end-day-time
-			 (gnc:timepair-previous-day start-date-printable)))
-         (end-date-tp (gnc:timepair-end-day-time 
+         (start-date (gnc:time64-end-day-time
+			 (gnc:time64-previous-day start-date-printable)))
+         (end-date (gnc:time64-end-day-time 
 		       (gnc:date-option-absolute-time
 			(get-option gnc:pagename-general
 				    optname-end-date))))
@@ -270,10 +270,10 @@
          ;; exchange rates calculation parameters
 	 (start-exchange-fn
 	  (gnc:case-exchange-fn
-	   price-source report-commodity start-date-tp))
+	   price-source report-commodity start-date))
 	 (end-exchange-fn
 	  (gnc:case-exchange-fn
-	   price-source report-commodity end-date-tp))
+	   price-source report-commodity end-date))
 	 )
     
     (gnc:html-document-set-title! 
@@ -281,8 +281,8 @@
 		  (string-append "%s %s "
 				 (_ "For Period Covering %s to %s"))
 		  company-name report-title
-                  (gnc-print-date start-date-printable)
-                  (gnc-print-date end-date-tp)))
+                  (qof-print-date start-date-printable)
+                  (qof-print-date end-date)))
     
     (if (null? accounts)
 	
@@ -336,17 +336,17 @@
 	       (get-start-balance-fn
 		(lambda (account)
 		  (gnc:account-get-comm-balance-at-date 
-		   account start-date-tp #f)))
+		   account start-date #f)))
 	       (get-end-balance-fn
 		(lambda (account)
 		  (gnc:account-get-comm-balance-at-date 
-		   account end-date-tp #f)))
+		   account end-date #f)))
 	       (terse-period? #t)
 	       (period-for (if terse-period?
 			       (string-append " " (_ "for Period"))
 			       (sprintf #f (string-append ", " (_ "%s to %s"))
-					(gnc-print-date start-date-printable)
-					(gnc-print-date end-date-tp))
+					(qof-print-date start-date-printable)
+					(qof-print-date end-date))
 			       ))
 	       )
 	  
@@ -396,11 +396,11 @@
 	  ;; equity constitutes an unrealized loss.  I'm unsure about
 	  ;; that though....
 	  ;; 
-	  (define (unrealized-gains-at-date book-balance exchange-fn date-tp)
+	  (define (unrealized-gains-at-date book-balance exchange-fn date)
 	    (let* ((unrealized-gain-collector (gnc:make-commodity-collector))
 		   (weighted-fn
 		    (gnc:case-exchange-fn 'weighted-average
-					  report-commodity date-tp))
+					  report-commodity date))
 		   
 		   (value
 		    (gnc:gnc-monetary-amount
@@ -445,10 +445,10 @@
 	  ;; start and end retained earnings (income - expenses)
 	  (set! neg-pre-start-retained-earnings
 		(gnc:accountlist-get-comm-balance-at-date-with-closing
-		 income-expense-accounts start-date-tp)) ; OK
+		 income-expense-accounts start-date)) ; OK
 	  (set! neg-pre-end-retained-earnings
 		(gnc:accountlist-get-comm-balance-at-date-with-closing
-		 income-expense-accounts end-date-tp)) ; OK
+		 income-expense-accounts end-date)) ; OK
 	  ;; neg-pre-end-retained-earnings is not used to calculate
 	  ;; profit but is used to calculate unrealized gains
 	  
@@ -457,13 +457,13 @@
 	  (set! income-expense-closing
 		(gnc:account-get-trans-type-balance-interval-with-closing
 		 income-expense-accounts closing-pattern
-		 start-date-tp end-date-tp)
+		 start-date end-date)
 		)
 	  ;; find retained earnings for the period
 	  (set! neg-net-income
 		(gnc:accountlist-get-comm-balance-interval-with-closing
 		 income-expense-accounts
-		 start-date-tp end-date-tp)) ; OK
+		 start-date end-date)) ; OK
 	  ;; revert the income/expense to its pre-closing balance
 	  (neg-net-income 'minusmerge income-expense-closing #f)
 	  (set! net-income (gnc:make-commodity-collector))
@@ -502,7 +502,7 @@
 	  (set! start-unrealized-gains
 		(unrealized-gains-at-date start-book-balance
 					  start-exchange-fn
-					  start-date-tp)) ; OK
+					  start-date)) ; OK
 	  ;; I suspect that unrealized gains (since never realized)
 	  ;; must be counted from forever-ago....
 	  ;; ...yep, this appears to be correct.
@@ -510,7 +510,7 @@
 	  (set! end-unrealized-gains
 		(unrealized-gains-at-date end-book-balance
 					  end-exchange-fn
-					  end-date-tp)) ; OK
+					  end-date)) ; OK
 	  
 	  ;; unrealized gains accrued during the reporting period...
 	  (set! net-unrealized-gains (gnc:make-commodity-collector))
@@ -534,7 +534,7 @@
 	  (set! equity-closing 
 		(gnc:account-get-trans-type-balance-interval-with-closing
 		 equity-accounts closing-pattern
-		 start-date-tp end-date-tp)
+		 start-date end-date)
 		)
 	  (set! neg-pre-closing-equity (gnc:make-commodity-collector))
 	  (neg-pre-closing-equity 'merge neg-end-equity-balance #f)
@@ -544,7 +544,7 @@
 	  (net-investment 'minusmerge neg-pre-closing-equity #f);; > 0
 	  (net-investment 'merge neg-start-equity-balance #f)   ;; net increase
 
-	  (set! withdrawals (gnc:account-get-total-flow 'in  equity-accounts start-date-tp end-date-tp))
+	  (set! withdrawals (gnc:account-get-total-flow 'in  equity-accounts start-date end-date))
 
 	  (set! investments (gnc:make-commodity-collector))
 	  (investments 'merge net-investment #f)
@@ -584,7 +584,7 @@
 	  (report-line
 	   build-table
 	   (string-append (_ "Capital") ", "
-			  (gnc-print-date start-date-printable))
+			  (qof-print-date start-date-printable))
 	   #f start-total-equity
 	   1 start-exchange-fn #f "primary-subheading"
 	   )
@@ -628,7 +628,7 @@
 	  (report-line
 	   build-table 
 	   (string-append (_ "Capital") ", "
-			  (gnc-print-date end-date-tp))
+			  (qof-print-date end-date))
 	   #f
 	   end-total-equity
 	   1 end-exchange-fn #f "primary-subheading"
@@ -641,8 +641,8 @@
           (and show-rates?
 	       (let* ((curr-tbl (gnc:make-html-table))
 		      (headers (list
-				(gnc-print-date start-date-printable)
-				(gnc-print-date end-date-tp)
+				(qof-print-date start-date-printable)
+				(qof-print-date end-date)
 				)
 			       )
 		      (then (gnc:html-make-exchangerates

commit 7488565b9bade01a35e716791ef98afbf938c42d
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Nov 25 00:20:19 2017 +0800

    TP->T64: gnucash/report/standard-reports/balance-sheet.scm

diff --git a/gnucash/report/standard-reports/balance-sheet.scm b/gnucash/report/standard-reports/balance-sheet.scm
index e79d85c..04debb1 100644
--- a/gnucash/report/standard-reports/balance-sheet.scm
+++ b/gnucash/report/standard-reports/balance-sheet.scm
@@ -294,11 +294,11 @@
   (let* (
 	 (report-title (get-option gnc:pagename-general optname-report-title))
 	 (company-name (get-option gnc:pagename-general optname-party-name))
-         (date-tp (gnc:timepair-end-day-time 
+         (reportdate (gnc:time64-end-day-time 
                       (gnc:date-option-absolute-time
                        (get-option gnc:pagename-general
                                    optname-date))))
-         (date-secs (gnc:timepair->secs date-tp))
+         (date-secs reportdate)
          (report-form? (get-option gnc:pagename-general
                                optname-report-form))
          (standard-order? (get-option gnc:pagename-general 
@@ -373,9 +373,8 @@
                          (gnc:get-current-account-tree-depth) 
 			 depth-limit))
          ;; exchange rates calculation parameters
-	 (exchange-fn
-	  (gnc:case-exchange-fn price-source report-commodity date-tp))
-	 )
+         (exchange-fn
+          (gnc:case-exchange-fn price-source report-commodity reportdate)))
     
     ;; Wrapper to call gnc:html-table-add-labeled-amount-line!
     ;; with the proper arguments.
@@ -452,7 +451,7 @@
     ;;(gnc:warn "account names" liability-account-names)
     (gnc:html-document-set-title! 
      doc (string-append company-name " " report-title " "
-			(gnc-print-date date-tp))
+                        (qof-print-date reportdate))
      )
     
     (if (null? accounts)
@@ -492,10 +491,10 @@
 	       (get-total-balance-fn
 		(lambda (account)
 		  (gnc:account-get-comm-balance-at-date 
-		   account date-tp #f)))
+		   account reportdate #f)))
                (get-total-value-fn
                 (lambda (account)
-                  (gnc:account-get-comm-value-at-date account date-tp #f)))
+                  (gnc:account-get-comm-value-at-date account reportdate #f)))
 	       )
 	  
 	  ;; If you ask me, any outstanding(TM) retained earnings and
@@ -544,12 +543,12 @@
           ;; commodity trading accounts they will automatically accumulate the gains.
           (set! unrealized-gain-collector (gnc:make-commodity-collector))
           (if compute-unrealized-gains?
-              (let ((asset-basis 
-                     (gnc:accounts-get-comm-total-assets asset-accounts
-                                                         get-total-value-fn))
-                    (neg-liability-basis 
-                     (gnc:accounts-get-comm-total-assets liability-accounts
-                                                         get-total-value-fn)))
+              (let ((asset-basis (gnc:accounts-get-comm-total-assets
+                                  asset-accounts
+                                  get-total-value-fn))
+                    (neg-liability-basis (gnc:accounts-get-comm-total-assets
+                                          liability-accounts
+                                          get-total-value-fn)))
                 ;; Calculate unrealized gains from assets.
                 (unrealized-gain-collector 'merge asset-balance #f)
                 (unrealized-gain-collector 'minusmerge asset-basis #f)
@@ -590,7 +589,7 @@
 	  (set! table-env
 		(list
 		 (list 'start-date #f)
-		 (list 'end-date date-tp)
+		 (list 'end-date reportdate)
 		 (list 'display-tree-depth tree-depth)
 		 (list 'depth-limit-behavior (if bottom-behavior
 						 'flatten
@@ -743,9 +742,7 @@
     
     (gnc:report-finished)
     
-    doc
-    )
-  )
+    doc))
 
 (gnc:define-report 
  'version 1

commit 6e7ad4a278b9aed2aadc85938923224e1b8279af
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Jan 8 18:24:55 2018 +1100

    TP->T64: gnucash/report/standard-reports/average-balance.scm

diff --git a/gnucash/report/standard-reports/average-balance.scm b/gnucash/report/standard-reports/average-balance.scm
index 2fafaf2..db45f0f 100644
--- a/gnucash/report/standard-reports/average-balance.scm
+++ b/gnucash/report/standard-reports/average-balance.scm
@@ -169,11 +169,11 @@
                         gain-loss-accum)
       (set! data-rows
             (cons 
-             (list (gnc-print-date interval-start)
-                   (gnc-print-date interval-end)
+             (list (qof-print-date interval-start)
+                   (qof-print-date interval-end)
                    (/ (stats-accum 'total #f)
-                      (gnc:timepair-delta interval-start 
-                                          interval-end))
+                      (- interval-end
+                         interval-start))
                    (minmax-accum 'getmax #f)
                    (minmax-accum 'getmin #f)
                    (gain-loss-accum 'debits #f) 
@@ -213,9 +213,8 @@
         
         
         (define (update-stats  split-amt split-time)
-          (let ((time-difference (gnc:timepair-delta 
-                                  last-balance-time
-                                  split-time)))
+          (let ((time-difference (- split-time
+                                    last-balance-time)))
             (stats-accum 'add (* last-balance time-difference))
             (set! last-balance (+ last-balance split-amt))
             (set! last-balance-time split-time)
@@ -223,15 +222,13 @@
             (gain-loss-accum 'add split-amt)))
 
         (define (split-recurse)
-          (if (or (null? splits) (gnc:timepair-gt 
-                                  (gnc-transaction-get-date-posted
-                                   (xaccSplitGetParent
-                                    (car splits))) to)) 
+          (if (or (null? splits)
+                  (> (xaccTransGetDate (xaccSplitGetParent (car splits)))
+                     to))
               #f
               (let* 
                   ((split (car splits))
-                   (split-time (gnc-transaction-get-date-posted
-                                (xaccSplitGetParent split)))
+                   (split-time (xaccTransGetDate (xaccSplitGetParent split)))
                    ;; FIXME: Which date should we use here? The 'to'
                    ;; date? the 'split-time'?
 		   (split-amt (get-split-value split split-time))
@@ -323,10 +320,10 @@
   (gnc:report-starting reportname)
   (let* ((report-title (get-option gnc:pagename-general 
                                    gnc:optname-reportname))
-         (begindate (gnc:timepair-start-day-time
+         (begindate (gnc:time64-start-day-time
                      (gnc:date-option-absolute-time 
                       (get-option gnc:pagename-general optname-from-date))))
-         (enddate (gnc:timepair-end-day-time 
+         (enddate (gnc:time64-end-day-time 
                    (gnc:date-option-absolute-time 
                     (get-option gnc:pagename-general optname-to-date))))
          (stepsize (gnc:deltasym-to-delta (get-option gnc:pagename-general optname-stepsize)))
@@ -348,8 +345,8 @@
 	 (commodity-list #f)
 	 (exchange-fn #f)
 
-         (beforebegindate (gnc:timepair-end-day-time 
-                           (gnc:timepair-previous-day begindate)))
+         (beforebegindate (gnc:time64-end-day-time 
+                           (gnc:time64-previous-day begindate)))
          (all-zeros? #t)
          ;; startbal will be a commodity-collector
          (startbal  '()))
@@ -423,7 +420,7 @@
           (xaccQueryAddAccountMatch query accounts QOF-GUID-MATCH-ANY QOF-QUERY-AND)
           
           ;; match splits between start and end dates 
-          (xaccQueryAddDateMatchTS
+          (xaccQueryAddDateMatchTT
            query #t begindate #t enddate QOF-QUERY-AND)
           (qof-query-set-sort-order query
 				    (list SPLIT-TRANS TRANS-DATE-POSTED)

commit 1fb69fdf5f3067c52be286c38c03b3adad474a72
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri Nov 24 23:50:46 2017 +0800

    TP->T64: gnucash/report/standard-reports/account-piecharts.scm

diff --git a/gnucash/report/standard-reports/account-piecharts.scm b/gnucash/report/standard-reports/account-piecharts.scm
index b07c641..0fc3b86 100644
--- a/gnucash/report/standard-reports/account-piecharts.scm
+++ b/gnucash/report/standard-reports/account-piecharts.scm
@@ -367,11 +367,11 @@ balance at a given time"))
   (gnc:report-starting reportname)
 
   ;; Get all options
-  (let ((to-date-tp (gnc:timepair-end-day-time 
+  (let ((to-date (gnc:time64-end-day-time 
                      (gnc:date-option-absolute-time
                       (get-option gnc:pagename-general optname-to-date))))
-        (from-date-tp (if do-intervals?
-                          (gnc:timepair-start-day-time 
+        (from-date (if do-intervals?
+                          (gnc:time64-start-day-time 
                            (gnc:date-option-absolute-time 
                             (get-option gnc:pagename-general 
 					optname-from-date)))
@@ -421,13 +421,13 @@ balance at a given time"))
     (define (profit-fn account subaccts?)
       (if do-intervals?
           (gnc:account-get-comm-balance-interval
-           account from-date-tp to-date-tp subaccts?)
+           account from-date to-date subaccts?)
           (gnc:account-get-comm-balance-at-date
-           account to-date-tp subaccts?)))
+           account to-date subaccts?)))
 
     ;; Define more helper variables.
     (let* ((exchange-fn (gnc:case-exchange-fn 
-                         price-source report-currency to-date-tp))
+                         price-source report-currency to-date))
            (tree-depth (if (equal? account-levels 'all)
                            (gnc:get-current-account-tree-depth)
                            account-levels))
@@ -436,10 +436,9 @@ balance at a given time"))
             (if averaging-fraction-func
                 ;; Calculate the divisor of the amounts so that an
                 ;; average is shown
-                (let* ((start-frac (averaging-fraction-func (gnc:timepair->secs from-date-tp)))
-                       (end-frac (averaging-fraction-func (+ 1 (gnc:timepair->secs to-date-tp))))
-                       (diff (- end-frac start-frac))
-                       )
+                (let* ((start-frac (averaging-fraction-func from-date))
+                       (end-frac (averaging-fraction-func (+ 1 to-date)))
+                       (diff (- end-frac start-frac)))
                   ;; Extra sanity check to ensure a positive number
                   (if (> diff 0)
                       (/ 1 diff)
@@ -567,11 +566,11 @@ balance at a given time"))
                        (if do-intervals?
                            (sprintf #f
                                     (_ "%s to %s")
-                                    (gnc-print-date from-date-tp)
-                                    (gnc-print-date to-date-tp))
+                                    (qof-print-date from-date)
+                                    (qof-print-date to-date))
                            (sprintf #f
                                     (_ "Balance at %s")
-                                    (gnc-print-date to-date-tp)))
+                                    (qof-print-date to-date)))
                        (if show-total?
                            (let ((total (apply + (unzip1 combined))))
                              (sprintf

commit a4fe4979854a4247dd1a1e6a823b3285d6c88e56
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri Nov 24 23:38:34 2017 +0800

    TP->T64: gnucash/report/standard-reports/advanced-portfolio.scm

diff --git a/gnucash/report/standard-reports/advanced-portfolio.scm b/gnucash/report/standard-reports/advanced-portfolio.scm
index 07fbf32..bf7cefb 100644
--- a/gnucash/report/standard-reports/advanced-portfolio.scm
+++ b/gnucash/report/standard-reports/advanced-portfolio.scm
@@ -535,11 +535,11 @@
 	       (gnc:report-percent-done (* 100 (/ work-done work-to-do)))
 
 	       (let* ((parent (xaccSplitGetParent split))
-		      (txn-date (gnc-transaction-get-date-posted parent))
+		      (txn-date (xaccTransGetDate parent))
 		      (commod-currency (xaccTransGetCurrency parent))
 		      (commod-currency-frac (gnc-commodity-get-fraction commod-currency)))
 
-		 (if (and (gnc:timepair-le txn-date to-date)
+		 (if (and (<= txn-date to-date)
 		          (not (assoc-ref seen_trans (gncTransGetGUID parent))))
 		     (let ((trans-income (gnc-numeric-zero))
 		           (trans-brokerage (gnc-numeric-zero))
@@ -828,9 +828,9 @@
 	                   ;; This is safe because xaccSplitGetAccount returns null for a null split
 	                   (other-acct (xaccSplitGetAccount other-split))
 	                   (parent (xaccSplitGetParent split))
-	                   (txn-date (gnc-transaction-get-date-posted parent)))
+	                   (txn-date (xaccTransGetDate parent)))
 	              (if (and (not (null? other-acct))
-	                       (gnc:timepair-le txn-date to-date)
+	                       (<= txn-date to-date)
 	                       (string=? (xaccAccountGetName other-acct) account-name)
 	                       (gnc-commodity-is-currency (xaccAccountGetCommodity other-acct)))
 	                ;; This is a two split transaction where the other split is to an
@@ -1025,7 +1025,7 @@
     (gnc:html-document-set-title!
      document (string-append
                report-title
-               (sprintf #f " %s" (gnc-print-date to-date))))
+               (sprintf #f " %s" (qof-print-date to-date))))
 
     (if (not (null? accounts))
         ; at least 1 account selected
@@ -1040,7 +1040,7 @@
                   ((pricedb-nearest)
                    (lambda (foreign domestic date)
                     (find-price (gnc-pricedb-lookup-nearest-in-time-any-currency
-		     pricedb foreign (timespecCanonicalDayTime date)) domestic)))))
+		     pricedb foreign (time64CanonicalDayTime date)) domestic)))))
 	       (headercols (list (_ "Account")))
 	       (totalscols (list (gnc:make-html-table-cell/markup "total-label-cell" (_ "Total"))))
 	       (sum-total-moneyin (gnc-numeric-zero))

commit c218c267ba38b4daac9b609d353250398e626e3c
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri Nov 24 23:12:35 2017 +0800

    TP->T64: gnucash/report/standard-reports/portfolio.scm

diff --git a/gnucash/report/standard-reports/portfolio.scm b/gnucash/report/standard-reports/portfolio.scm
index 548077b..4692d67 100644
--- a/gnucash/report/standard-reports/portfolio.scm
+++ b/gnucash/report/standard-reports/portfolio.scm
@@ -191,7 +191,7 @@
     (gnc:html-document-set-title!
      document (string-append
                report-title
-               (sprintf #f " %s" (gnc-print-date to-date))))
+               (sprintf #f " %s" (qof-print-date to-date))))
 
     ;(gnc:debug "accounts" accounts)
     (if (not (null? accounts))
@@ -235,7 +235,7 @@
                    (lambda (foreign date)
                      (let*  ((price
                              (gnc-pricedb-lookup-nearest-in-time-any-currency
-                              pricedb foreign (timespecCanonicalDayTime date)))
+                              pricedb foreign (time64CanonicalDayTime date)))
                             (fn (if (and price (> (length price) 0))
                                     (let* ((the_price
                                             (if (gnc-commodity-equiv

commit b1a73291d48eae4c422a90213a931a3bb22bb055
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue Dec 19 23:14:16 2017 +0800

    TP->T64: gnucash/report/standard-reports/trial-balance.scm

diff --git a/gnucash/report/standard-reports/trial-balance.scm b/gnucash/report/standard-reports/trial-balance.scm
index e4b8ba4..1b058e3 100644
--- a/gnucash/report/standard-reports/trial-balance.scm
+++ b/gnucash/report/standard-reports/trial-balance.scm
@@ -302,9 +302,9 @@
          (start-date-printable (gnc:date-option-absolute-time
 				(get-option gnc:pagename-general
 					    optname-start-date)))
-         (start-date-tp (gnc:timepair-end-day-time
-			 (gnc:timepair-previous-day start-date-printable)))
-         (end-date-tp (gnc:timepair-end-day-time 
+         (start-date (gnc:time64-end-day-time
+			 (gnc:time64-previous-day start-date-printable)))
+         (end-date (gnc:time64-end-day-time 
 		       (gnc:date-option-absolute-time
 			(get-option gnc:pagename-general
 				    optname-end-date))))
@@ -384,13 +384,13 @@
 	 (doc (gnc:make-html-document))
          ;; exchange rates calculation parameters
 	 (exchange-fn
-	  (gnc:case-exchange-fn price-source report-commodity end-date-tp))
+	  (gnc:case-exchange-fn price-source report-commodity end-date))
 	 (terse-period? #t)
 	 (period-for (if terse-period?
 			 (string-append " " (_ "for Period"))
 			 (sprintf #f (string-append ", " (_ "%s to %s"))
-				  (gnc-print-date start-date-printable)
-				  (gnc-print-date end-date-tp))
+				  (qof-print-date start-date-printable)
+				  (qof-print-date end-date))
 			 ))
 	 )
     
@@ -398,12 +398,12 @@
      doc (if (equal? report-variant 'current)
 	     (sprintf #f (string-append "%s %s %s")
 		      company-name report-title
-		      (gnc-print-date end-date-tp))
+		      (qof-print-date end-date))
 	     (sprintf #f (string-append "%s %s "
 					(_ "For Period Covering %s to %s"))
 		      company-name report-title
-		      (gnc-print-date start-date-printable)
-		      (gnc-print-date end-date-tp))
+		      (qof-print-date start-date-printable)
+		      (qof-print-date end-date))
 	     )
      )
     
@@ -523,7 +523,7 @@
                       (unrealized-gain-collector (gnc:make-commodity-collector))
                       (cost-fn (gnc:case-exchange-fn 'average-cost
                                                      report-commodity
-                                                     end-date-tp))
+                                                     end-date))
                       (value #f)
                       (cost #f))
 
@@ -533,7 +533,7 @@
                    (lambda (acct)
                      (book-balance 'merge
                                    (gnc:account-get-comm-balance-at-date
-                                    acct end-date-tp #f)
+                                    acct end-date #f)
                      #f))
                    all-accounts)
 
@@ -573,7 +573,7 @@
 	  (set! table-env
 		(list
 		 (list 'start-date #f)
-		 (list 'end-date end-date-tp)
+		 (list 'end-date end-date)
 		 (list 'display-tree-depth
 		       (if (integer? depth-limit) depth-limit #f))
 		 (list 'depth-limit-behavior 'flatten)
@@ -710,7 +710,7 @@
 				  (list 'regexp closing-regexp)
 				  (list 'closing #t)
 				  )
-			    start-date-tp end-date-tp
+			    start-date end-date
 			    ))
 			  (adjusting
 			   (gnc:account-get-trans-type-balance-interval-with-closing
@@ -719,7 +719,7 @@
 				  (list 'cased adjusting-cased)
 				  (list 'regexp adjusting-regexp)
 				  )
-			    start-date-tp end-date-tp
+			    start-date end-date
 			    ))
 			  (is? (member acct all-is-accounts))
 			  (ga-or-is? (or (member acct all-ga-accounts) is?))
@@ -733,7 +733,7 @@
 				       (list 'regexp adjusting-regexp)
 				       (list 'positive #t)
 				       )
-				 start-date-tp end-date-tp
+				 start-date end-date
 				 )
 				))
 			  (neg-adjusting
@@ -1136,9 +1136,7 @@
     
     (gnc:report-finished)
     
-    doc
-    )
-  )
+    doc))
 
 (gnc:define-report 
  'version 1
@@ -1153,4 +1151,3 @@
 		 (trial-balance-renderer report-obj #f filename)))
 
 ;; END
-

commit ecdea5dd5e271ea266753b9c03b6e2f9db4559ff
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Nov 22 22:46:18 2017 +0800

    TP->T64: gnucash/report/standard-reports/income-statement.scm

diff --git a/gnucash/report/standard-reports/income-statement.scm b/gnucash/report/standard-reports/income-statement.scm
index be70302..ca1fcb7 100644
--- a/gnucash/report/standard-reports/income-statement.scm
+++ b/gnucash/report/standard-reports/income-statement.scm
@@ -302,11 +302,11 @@
          (start-date-printable (gnc:date-option-absolute-time
 				(get-option gnc:pagename-general
 					    optname-start-date)))
-         (start-date-tp (gnc:timepair-start-day-time
+         (start-date (gnc:time64-start-day-time
 			 (gnc:date-option-absolute-time
 			  (get-option gnc:pagename-general
 				      optname-start-date))))
-         (end-date-tp (gnc:timepair-end-day-time
+         (end-date (gnc:time64-end-day-time
 		       (gnc:date-option-absolute-time
 			(get-option gnc:pagename-general
 				    optname-end-date))))
@@ -388,7 +388,7 @@
 			 depth-limit))
          ;; exchange rates calculation parameters
 	 (exchange-fn
-	  (gnc:case-exchange-fn price-source report-commodity end-date-tp))
+	  (gnc:case-exchange-fn price-source report-commodity end-date))
 	 )
     
     ;; Wrapper to call gnc:html-table-add-labeled-amount-line!
@@ -434,8 +434,8 @@
 		  (string-append "%s %s "
 				 (_ "For Period Covering %s to %s"))
 		  company-name report-title
-                  (gnc-print-date start-date-printable)
-                  (gnc-print-date end-date-tp)))
+                  (qof-print-date start-date-printable)
+                  (qof-print-date end-date)))
     
     (if (null? accounts)
 	
@@ -473,8 +473,8 @@
 	       (period-for (if terse-period?
 			       (string-append " " (_ "for Period"))
 			       (sprintf #f (string-append ", " (_ "%s to %s"))
-					(gnc-print-date start-date-printable)
-					(gnc-print-date end-date-tp))
+					(qof-print-date start-date-printable)
+					(qof-print-date end-date))
 			       )
 			   )
 	       )
@@ -518,29 +518,29 @@
 	  (set! revenue-closing
 		(gnc:account-get-trans-type-balance-interval-with-closing
 		 revenue-accounts closing-pattern
-		 start-date-tp end-date-tp)
+		 start-date end-date)
 		) ;; this is norm positive (debit)
 	  (set! expense-closing
 		(gnc:account-get-trans-type-balance-interval-with-closing
 		 expense-accounts closing-pattern
-		 start-date-tp end-date-tp)
+		 start-date end-date)
 		) ;; this is norm negative (credit)
 	  (set! expense-total
 		(gnc:accountlist-get-comm-balance-interval-with-closing
 		 expense-accounts
-		 start-date-tp end-date-tp))
+		 start-date end-date))
 	  (expense-total 'minusmerge expense-closing #f)
 	  (set! neg-revenue-total
 		(gnc:accountlist-get-comm-balance-interval-with-closing
 		 revenue-accounts
-		 start-date-tp end-date-tp))
+		 start-date end-date))
 	  (neg-revenue-total 'minusmerge revenue-closing #f)
 	  (set! revenue-total (gnc:make-commodity-collector))
 	  (revenue-total 'minusmerge neg-revenue-total #f)
           (set! trading-total 
                 (gnc:accountlist-get-comm-balance-interval-with-closing
                  trading-accounts
-                 start-date-tp end-date-tp))
+                 start-date end-date))
 	  ;; calculate net income
 	  (set! net-income (gnc:make-commodity-collector))
 	  (net-income 'merge revenue-total #f)
@@ -549,8 +549,8 @@
 	  
 	  (set! table-env
 		(list
-		 (list 'start-date start-date-tp)
-		 (list 'end-date end-date-tp)
+		 (list 'start-date start-date)
+		 (list 'end-date end-date)
 		 (list 'display-tree-depth tree-depth)
 		 (list 'depth-limit-behavior (if bottom-behavior
 						 'flatten
@@ -714,9 +714,7 @@
     
     (gnc:report-finished)
     
-    doc
-    )
-  )
+    doc))
 
 (define is-reportname (N_ "Income Statement"))
 (define pnl-reportname (N_ "Profit & Loss"))
@@ -738,8 +736,7 @@
  'report-guid "0b81a3bdfd504aff849ec2e8630524bc"
  'menu-path (list gnc:menuname-income-expense)
  'options-generator income-statement-options-generator
- 'renderer income-statement-renderer
- )
+ 'renderer income-statement-renderer)
 
 ;; Also make a "Profit & Loss" report, even if it's the exact same one,
 ;; just relabeled.
@@ -749,7 +746,6 @@
  'report-guid "8758ba23984c40dea5527f5f0ca2779e"
  'menu-path (list gnc:menuname-income-expense)
  'options-generator profit-and-loss-options-generator
- 'renderer profit-and-loss-renderer
- )
+ 'renderer profit-and-loss-renderer)
 
 ;; END

commit 59a8a42f7de0e93d957ede2d78c6682e2b72a7d7
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Jan 8 18:35:46 2018 +1100

    TP->T64: gnucash/report/standard-reports/daily-reports.scm

diff --git a/gnucash/report/standard-reports/daily-reports.scm b/gnucash/report/standard-reports/daily-reports.scm
index 219cf89..79eab76 100644
--- a/gnucash/report/standard-reports/daily-reports.scm
+++ b/gnucash/report/standard-reports/daily-reports.scm
@@ -2,6 +2,7 @@
 ;; daily-reports.scm: reports based on the day of the week
 ;;
 ;; Copyright (C) 2003, Andy Wingo <wingo at pobox dot com>
+;; Christopher Lam upgrade to time64 (2017)
 ;;
 ;; based on account-piecharts.scm by Robert Merkel (rgmerk at mira.net)
 ;; and Christian Stimming <stimming at tu-harburg.de> with
@@ -154,8 +155,8 @@
              (list interval-start
                    interval-end
                    (/ (stats-accum 'total #f)
-                      (gnc:timepair-delta interval-start 
-                                          interval-end))
+                      (- interval-end 
+                         interval-start))
                    (minmax-accum 'getmax #f)
                    (minmax-accum 'getmin #f)
                    (gain-loss-accum 'debits #f) 
@@ -195,9 +196,8 @@
         
         
         (define (update-stats  split-amt split-time)
-          (let ((time-difference (gnc:timepair-delta 
-                                  last-balance-time
-                                  split-time)))
+          (let ((time-difference (- split-time
+                                    last-balance-time)))
             (stats-accum 'add (* last-balance time-difference))
             (set! last-balance (+ last-balance split-amt))
             (set! last-balance-time split-time)
@@ -205,15 +205,13 @@
             (gain-loss-accum 'add split-amt)))
 
         (define (split-recurse)
-          (if (or (null? splits) (gnc:timepair-gt 
-                                  (gnc-transaction-get-date-posted
-                                   (xaccSplitGetParent
-                                    (car splits))) to)) 
+          (if (or (null? splits)
+                  (> (xaccTransGetDate (xaccSplitGetParent (car splits)))
+                     to))
               #f
               (let* 
                   ((split (car splits))
-                   (split-time (gnc-transaction-get-date-posted
-                                (xaccSplitGetParent split)))
+                   (split-time (xaccTransGetDate (xaccSplitGetParent split)))
                    ;; FIXME: Which date should we use here? The 'to'
                    ;; date? the 'split-time'?
                    (split-amt (get-split-value split split-time)))
@@ -225,7 +223,7 @@
 ;                (gnc:debug "splits " splits)
                 (update-stats split-amt split-time)
                 (set! splits (cdr splits))
-		(split-recurse))))
+                (split-recurse))))
 
                                         ;  the minmax accumulator
 
@@ -237,16 +235,14 @@
         ;; insert a null transaction at the end of the interval
         (update-stats 0.0 to)
         (list minmax-accum stats-accum gain-loss-accum last-balance splits)))
-    
-    
+
     (for-each
      (lambda (interval)
-       (let* 
-           
-           ((interval-results 
-             (process-interval 
-              splits 
-              (car interval) 
+       (let*
+           ((interval-results
+             (process-interval
+              splits
+              (car interval)
               (cadr interval)
               start-bal-double))
             (min-max-accum (car interval-results))
@@ -261,8 +257,7 @@
                      (cadr interval) 
                      stats-accum 
                      min-max-accum gain-loss-accum)))
-     interval-list)
-    
+     interval-list)    
     
     (reverse data-rows)))
 
@@ -283,10 +278,10 @@
   (gnc:report-starting reportname)
 
   ;; Get all options
-  (let* ((to-date-tp (gnc:timepair-end-day-time 
+  (let* ((to-date (gnc:time64-end-day-time 
                      (gnc:date-option-absolute-time
                       (get-option gnc:pagename-general optname-to-date))))
-         (from-date-tp (gnc:timepair-start-day-time 
+         (from-date (gnc:time64-start-day-time 
                         (gnc:date-option-absolute-time 
                          (get-option gnc:pagename-general 
                                      optname-from-date))))
@@ -308,8 +303,8 @@
          (exchange-fn #f)
          (print-info (gnc-commodity-print-info report-currency #t))
         
-         (beforebegindate (gnc:timepair-end-day-time 
-                           (gnc:timepair-previous-day from-date-tp)))
+         (beforebegindate (gnc:time64-end-day-time 
+                           (gnc:time64-previous-day from-date)))
          (document (gnc:make-html-document))
          (chart (gnc:make-html-piechart))
          (topl-accounts (gnc:filter-accountlist-type 
@@ -372,7 +367,7 @@
 	  (gnc:report-percent-done 5)
 	  (set! exchange-fn (gnc:case-exchange-time-fn 
                              price-source report-currency 
-                             commodity-list to-date-tp
+                             commodity-list to-date
 			     5 20))
 	  (gnc:report-percent-done 20)
           
@@ -406,8 +401,8 @@
           (xaccQueryAddAccountMatch query accounts QOF-GUID-MATCH-ANY QOF-QUERY-AND)
           
           ;; match splits between start and end dates 
-          (xaccQueryAddDateMatchTS
-           query #t from-date-tp #t to-date-tp QOF-QUERY-AND)
+          (xaccQueryAddDateMatchTT
+           query #t from-date #t to-date QOF-QUERY-AND)
           (qof-query-set-sort-order query
 				    (list SPLIT-TRANS TRANS-DATE-POSTED)
 				    (list QUERY-DEFAULT-SORT)
@@ -438,7 +433,7 @@
 	  
           ;; and analyze the data 
           (set! data (analyze-splits splits startbal
-                                     from-date-tp to-date-tp 
+                                     from-date to-date 
                                      DayDelta monetary->double))
 	  (gnc:report-percent-done 70)
           
@@ -448,7 +443,7 @@
           
           (for-each
            (lambda (split)
-             (let ((k (modulo (- (gnc:timepair-get-week-day
+             (let ((k (modulo (- (gnc:time64-get-week-day
                                   (list-ref split 1)) 1) 7))) ; end-date
                (list-set! daily-totals k
                           (+ (list-ref daily-totals k)
@@ -482,8 +477,8 @@
                    chart (string-append
                           (sprintf #f
                                    (_ "%s to %s")
-                                   (gnc-print-date from-date-tp)
-                                   (gnc-print-date to-date-tp))
+                                   (qof-print-date from-date)
+                                   (qof-print-date to-date))
                           (if show-total?
                               (let ((total (apply + daily-totals)))
                                 (sprintf

commit 78ea4545f33f553e113eb17fcbf8e52e99c5fb66
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Nov 22 21:18:46 2017 +0800

    TP->T64: gnucash/report/standard-reports/sx-summary.scm

diff --git a/gnucash/report/standard-reports/sx-summary.scm b/gnucash/report/standard-reports/sx-summary.scm
index 9d02186..4fdab6d 100644
--- a/gnucash/report/standard-reports/sx-summary.scm
+++ b/gnucash/report/standard-reports/sx-summary.scm
@@ -5,6 +5,7 @@
 ;; Copyright 2004 David Montenegro <sunrise2000 at comcast.net>
 ;; Copyright 2001 Christian Stimming <stimming at tu-harburg.de>
 ;; Copyright 2000-2001 Bill Gribble <grib at gnumatic.com>
+;; Copyright 2017 Christopher Lam upgrade to time64
 ;;    
 ;; This program is free software; you can redistribute it and/or    
 ;; modify it under the terms of the GNU General Public License as   
@@ -41,7 +42,6 @@
 
 (gnc:module-load "gnucash/report/report-system" 0)
 
-
 (define reportname (N_ "Future Scheduled Transactions Summary"))
 
 (define optname-report-title (N_ "Report Title"))
@@ -249,11 +249,11 @@
   (let* (
 	 (report-title (get-option gnc:pagename-general optname-report-title))
 	 (company-name (get-option gnc:pagename-general optname-party-name))
-         (from-date-tp (gnc:timepair-start-day-time 
+         (from-date (gnc:time64-start-day-time 
                         (gnc:date-option-absolute-time
                          (get-option gnc:pagename-general
                                      optname-from-date))))
-         (to-date-tp (gnc:timepair-end-day-time 
+         (to-date (gnc:time64-end-day-time 
                       (gnc:date-option-absolute-time
                        (get-option gnc:pagename-general
                                    optname-to-date))))
@@ -306,7 +306,7 @@
 			 depth-limit))
          ;; exchange rates calculation parameters
 	 (exchange-fn
-	  (gnc:case-exchange-fn price-source report-commodity to-date-tp))
+	  (gnc:case-exchange-fn price-source report-commodity to-date))
 	 )
     
     (gnc:html-document-set-title! 
@@ -314,8 +314,8 @@
 		  (string-append "%s %s "
 				 (_ "For Period Covering %s to %s"))
 		  company-name report-title
-                  (gnc-print-date from-date-tp)
-                  (gnc-print-date to-date-tp))
+                  (qof-print-date from-date)
+                  (qof-print-date to-date))
      )
     
     (if (null? accounts)
@@ -330,14 +330,14 @@
 	
 	;; otherwise, generate the report...
 	(let* (
-               (sx-value-hash (gnc-sx-all-instantiate-cashflow-all from-date-tp to-date-tp))
+               (sx-value-hash (gnc-sx-all-instantiate-cashflow-all from-date to-date))
 	       (chart-table #f)                    ;; gnc:html-acct-table
 	       (hold-table (gnc:make-html-table))  ;; temporary gnc:html-table
 	       (build-table (gnc:make-html-table)) ;; gnc:html-table reported
 	       (table-env                      ;; parameters for :make-
 		(list
-		 (list 'start-date from-date-tp)
-		 (list 'end-date to-date-tp)
+		 (list 'start-date from-date)
+		 (list 'end-date to-date)
 		 (list 'display-tree-depth tree-depth)
 		 (list 'depth-limit-behavior bottom-behavior)
 		 (list 'report-commodity report-commodity)
@@ -506,8 +506,7 @@
 	)
     
     (gnc:report-finished)
-    doc)
-  )
+    doc))
 
 (gnc:define-report 
  'version 1

commit b2eb687c37b6780b425f04cd5a6a85ce00e18ea1
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue Nov 21 06:50:52 2017 +0800

    TP->T64: gnucash/report/standard-reports/price-scatter.scm

diff --git a/gnucash/report/standard-reports/price-scatter.scm b/gnucash/report/standard-reports/price-scatter.scm
index 5df439d..08882a0 100644
--- a/gnucash/report/standard-reports/price-scatter.scm
+++ b/gnucash/report/standard-reports/price-scatter.scm
@@ -140,14 +140,14 @@
      (gnc:make-gnc-monetary c n)))
 
 
-  (let* ((to-date-tp (gnc:timepair-end-day-time 
-                      (gnc:date-option-absolute-time
-                       (get-option gnc:pagename-general 
-                                   optname-to-date))))
-         (from-date-tp (gnc:timepair-start-day-time 
-                        (gnc:date-option-absolute-time
-                         (get-option gnc:pagename-general 
-                                     optname-from-date))))
+  (let* ((to-date (gnc:time64-end-day-time 
+                   (gnc:date-option-absolute-time
+                    (get-option gnc:pagename-general 
+                                optname-to-date))))
+         (from-date (gnc:time64-start-day-time 
+                     (gnc:date-option-absolute-time
+                      (get-option gnc:pagename-general 
+                                  optname-from-date))))
          (interval (get-option gnc:pagename-general optname-stepsize))
          (report-title (get-option gnc:pagename-general 
                                    gnc:optname-reportname))
@@ -168,9 +168,9 @@
                                    optname-price-source))
 
          (dates-list (gnc:make-date-list
-                      (gnc:timepair-end-day-time from-date-tp) 
-                      (gnc:timepair-end-day-time to-date-tp)
-		      (gnc:deltasym-to-delta interval)))
+                      (gnc:time64-end-day-time from-date) 
+                      (gnc:time64-end-day-time to-date)
+                      (gnc:deltasym-to-delta interval)))
          
          (document (gnc:make-html-document))
          (chart (gnc:make-html-scatter))
@@ -200,8 +200,8 @@
             " - "
             (sprintf #f
                      (_ "%s to %s")
-                     (gnc-print-date from-date-tp)
-                     (gnc-print-date to-date-tp))))
+                     (qof-print-date from-date)
+                     (qof-print-date to-date))))
     (gnc:html-scatter-set-width! chart width)
     (gnc:html-scatter-set-height! chart height)
     (gnc:html-scatter-set-marker! chart 
@@ -241,15 +241,15 @@
             (case price-source
               ((actual-transactions)
                (gnc:get-commodity-inst-prices
-                currency-accounts to-date-tp 
+                currency-accounts to-date 
                 price-commodity report-currency))
               ((weighted-average)
                (gnc:get-commodity-totalavg-prices
-                currency-accounts to-date-tp 
+                currency-accounts to-date 
                 price-commodity report-currency))
               ((pricedb)
                (map (lambda (p)
-                      (list (gnc-price-get-time p)
+                      (list (gnc-price-get-time64 p)
                             (gnc-price-get-value p)))
                     (gnc-pricedb-get-prices
                      (gnc-pricedb-get-db (gnc-get-current-book))
@@ -257,15 +257,15 @@
               )))
 
        (set! data (filter
-                   (lambda (x) 
+                   (lambda (x)
                      (and 
-                      (gnc:timepair-ge to-date-tp (first x))
-                      (gnc:timepair-ge (first x) from-date-tp)))
+                      (>= to-date (first x))
+                      (>= (first x) from-date)))
                    data))
 
        ;; some output
        ;;(warn "data" (map (lambda (x) (list
-       ;;			(gnc-print-date (car x))
+       ;;			(qof-print-date x)
        ;;		(gnc-numeric-to-double (second x))))
        ;; data))
        
@@ -285,8 +285,8 @@
        (set! data
              (map (lambda (x)
                     (list
-                     (/ (- (car (first x))
-                           (car from-date-tp))
+                     (/ (- (first x)
+                           from-date)
                         ;; FIXME: These hard-coded values are more
                         ;; or less totally bogus. OTOH this whole
                         ;; scaling thing is totally bogus as well,

commit bca83e8480c05fedc97dcca29c30c76fbea28aa8
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue Nov 21 06:50:40 2017 +0800

    TP->T64: gnucash/report/standard-reports/account-summary.scm

diff --git a/gnucash/report/standard-reports/account-summary.scm b/gnucash/report/standard-reports/account-summary.scm
index 248b228..8c44eaf 100644
--- a/gnucash/report/standard-reports/account-summary.scm
+++ b/gnucash/report/standard-reports/account-summary.scm
@@ -161,9 +161,11 @@
                ACCT-TYPE-EQUITY ACCT-TYPE-INCOME ACCT-TYPE-EXPENSE)
 	 (gnc-account-get-descendants-sorted (gnc-get-current-root-account))))
       #f #t))
+    
     (gnc:options-add-account-levels!
      options gnc:pagename-accounts optname-depth-limit
      "b" opthelp-depth-limit 3)
+    
     (add-option
      (gnc:make-multichoice-option
       gnc:pagename-accounts optname-bottom-behavior
@@ -267,7 +269,7 @@
   (let* (
 	 (report-title (get-option gnc:pagename-general optname-report-title))
 	 (company-name (get-option gnc:pagename-general optname-party-name))
-         (date-tp (gnc:timepair-end-day-time 
+         (report-date (gnc:time64-end-day-time 
                       (gnc:date-option-absolute-time
                        (get-option gnc:pagename-general
                                    optname-date))))
@@ -320,12 +322,12 @@
 			 depth-limit))
          ;; exchange rates calculation parameters
 	 (exchange-fn
-	  (gnc:case-exchange-fn price-source report-commodity date-tp))
+	  (gnc:case-exchange-fn price-source report-commodity report-date))
 	 )
     
     (gnc:html-document-set-title! 
      doc (string-append company-name " " report-title " "
-			(gnc-print-date date-tp))
+			(qof-print-date report-date))
      )
     
     (if (null? accounts)
@@ -346,11 +348,11 @@
 	       (get-total-balance-fn
 		(lambda (account)
 		  (gnc:account-get-comm-balance-at-date 
-		   account date-tp #f)))
+		   account report-date #f)))
 	       (table-env                      ;; parameters for :make-
 		(list
 		 (list 'start-date #f)
-		 (list 'end-date date-tp)
+		 (list 'end-date report-date)
 		 (list 'display-tree-depth tree-depth)
 		 (list 'depth-limit-behavior bottom-behavior)
 		 (list 'report-commodity report-commodity)
@@ -501,8 +503,7 @@
 	)
     
     (gnc:report-finished)
-    doc)
-  )
+    doc))
 
 (gnc:define-report 
  'version 1

commit 4dcf7a535182beca190ab0cc43629eabd3572a70
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue Dec 19 23:11:36 2017 +0800

    TP->T64: gnucash/report/standard-reports/cash-flow.scm

diff --git a/gnucash/report/standard-reports/cash-flow.scm b/gnucash/report/standard-reports/cash-flow.scm
index cb2d200..9c55cf8 100644
--- a/gnucash/report/standard-reports/cash-flow.scm
+++ b/gnucash/report/standard-reports/cash-flow.scm
@@ -143,18 +143,18 @@
                                   optname-show-rates))
          (show-full-names? (get-option gnc:pagename-general 
                                        optname-show-full-names))
-         (from-date-tp (gnc:timepair-start-day-time 
+         (from-date-t64 (gnc:time64-start-day-time 
                         (gnc:date-option-absolute-time
                          (get-option gnc:pagename-general
                                      optname-from-date))))
-         (to-date-tp (gnc:timepair-end-day-time 
+         (to-date-t64 (gnc:time64-end-day-time 
                       (gnc:date-option-absolute-time
                        (get-option gnc:pagename-general
                                    optname-to-date))))
 
          ;; calculate the exchange rates
          (exchange-fn (gnc:case-exchange-fn
-                       price-source report-currency to-date-tp))
+                       price-source report-currency to-date-t64))
 
          (doc (gnc:make-html-document))
          (table (gnc:make-html-table))
@@ -162,10 +162,10 @@
 
     (gnc:html-document-set-title! 
      doc (string-append
-	  (get-option gnc:pagename-general gnc:optname-reportname)
-	  " - "
-	  (sprintf #f (_ "%s to %s")
-		   (gnc-print-date from-date-tp) (gnc-print-date to-date-tp))))
+          (get-option gnc:pagename-general gnc:optname-reportname)
+          " - "
+          (sprintf #f (_ "%s to %s")
+                   (qof-print-date from-date-t64) (qof-print-date to-date-t64))))
 
 
     ;; add subaccounts if requested
@@ -195,7 +195,7 @@
 	       ;; nearest available exchange rate if that is what is specified
 	       (time-exchange-fn (gnc:case-exchange-time-fn
 				  price-source report-currency
-				  commodity-list to-date-tp
+				  commodity-list to-date-t64
 				  0 0)))
 
 	  ;; Helper function to convert currencies
@@ -208,8 +208,8 @@
 
           (let ((result (cash-flow-calc-money-in-out
 			 (list (cons 'accounts accounts)
-			       (cons 'to-date-tp to-date-tp)
-			       (cons 'from-date-tp from-date-tp)
+			       (cons 'to-date-t64 to-date-t64)
+			       (cons 'from-date-t64 from-date-t64)
 			       (cons 'report-currency report-currency)
 			       (cons 'include-trading-accounts include-trading-accounts)
 			       (cons 'to-report-currency to-report-currency)))))
@@ -391,8 +391,8 @@
 ;; function to add inflow and outflow of money
 (define (cash-flow-calc-money-in-out settings)
   (let* ((accounts (cdr (assq 'accounts settings)))
-	 (to-date-tp (cdr (assq 'to-date-tp settings)))
-	 (from-date-tp (cdr (assq 'from-date-tp settings)))
+	 (to-date-t64 (cdr (assq 'to-date-t64 settings)))
+	 (from-date-t64 (cdr (assq 'from-date-t64 settings)))
 	 (report-currency (cdr (assq 'report-currency settings)))
 	 (include-trading-accounts (cdr (assq 'include-trading-accounts settings)))
 	 (to-report-currency (cdr (assq 'to-report-currency settings)))
@@ -407,7 +407,7 @@
 	 (money-out-hash (make-hash-table))
 	 (money-out-collector (gnc:make-commodity-collector))
 
-	 (all-splits (gnc:account-get-trans-type-splits-interval accounts '() from-date-tp to-date-tp))
+	 (all-splits (gnc:account-get-trans-type-splits-interval accounts '() from-date-t64 to-date-t64))
 	 (splits-to-do (length all-splits))
 	 (splits-seen-table (make-hash-table))
 	 (work-done 0))
@@ -423,8 +423,8 @@
       (if (= (modulo work-done 100) 0)
 	  (gnc:report-percent-done (* 85 (/ work-done splits-to-do))))
       (let ((parent (xaccSplitGetParent split)))
-	(if (and (gnc:timepair-le (gnc-transaction-get-date-posted parent) to-date-tp)
-		 (gnc:timepair-ge (gnc-transaction-get-date-posted parent) from-date-tp))
+	(if (and (<= (xaccTransGetDate parent) to-date-t64)
+		 (>= (xaccTransGetDate parent) from-date-t64))
 	    (let* ((parent-description (xaccTransGetDescription parent))
 		   (parent-currency (xaccTransGetCurrency parent)))
 					(gnc:debug parent-description
@@ -467,7 +467,7 @@
 				       )
 				   (let ((s-report-value (to-report-currency parent-currency
 									     (gnc-numeric-neg s-value)
-									     (gnc-transaction-get-date-posted
+									     (xaccTransGetDate
 									      parent))))
 				     (money-in-collector 'add report-currency s-report-value)
 				     (s-account-in-collector 'add report-currency s-report-value))
@@ -487,7 +487,7 @@
 				       )
 				   (let ((s-report-value (to-report-currency parent-currency
 									     s-value
-									     (gnc-transaction-get-date-posted
+									     (xaccTransGetDate
 									      parent))))
 				     (money-out-collector 'add report-currency s-report-value)
 				     (s-account-out-collector 'add report-currency s-report-value))

commit 22422f77596edbdda9c90b508c680cb64dfc42ea
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri Dec 22 22:23:04 2017 +0800

    TP->T64: gnucash/report/report-system/test/test-report-utilities.scm

diff --git a/gnucash/report/report-system/test/test-report-utilities.scm b/gnucash/report/report-system/test/test-report-utilities.scm
index 21a2532..2d5bf07 100644
--- a/gnucash/report/report-system/test/test-report-utilities.scm
+++ b/gnucash/report/report-system/test/test-report-utilities.scm
@@ -11,11 +11,10 @@
 (define (run-test)
   (test-account-get-trans-type-splits-interval))
 
-(define (NDayDelta tp n)
+(define (NDayDelta t64 n)
   (let* ((day-secs (* 60 60 24 n)) ; n days in seconds is n times 60 sec/min * 60 min/h * 24 h/day
-         (new-secs (- (car tp) day-secs))
-         (new-tp (cons new-secs 0)))
-    new-tp))
+         (new-secs (- t64 day-secs)))
+    new-secs))
 
 (define (test-account-get-trans-type-splits-interval)
   (let* ((env (create-test-env))
@@ -23,11 +22,11 @@
          (test-day (tm:mday ts-now))
          (test-month (+ 1 (tm:mon ts-now)))
          (test-year (+ 1900 (tm:year ts-now)))
-         (end-date-tp (gnc-dmy2timespec-neutral test-day test-month test-year))
-         (start-date-tp (NDayDelta end-date-tp 10))
-         (q-end-date-tp (gnc-dmy2timespec-end test-day test-month test-year))
-         (q-start-date-tp (gnc-dmy2timespec test-day test-month test-year))
-         (q-start-date-tp (NDayDelta q-start-date-tp 5)))
+         (end-date (gnc-dmy2time64-neutral test-day test-month test-year))
+         (start-date (NDayDelta end-date 10))
+         (q-end-date (gnc-dmy2time64-end test-day test-month test-year))
+         (q-start-date (gnc-dmy2time64 test-day test-month test-year))
+         (q-start-date (NDayDelta q-start-date 5)))
 
     (let* ((accounts (env-create-account-structure-alist env (list "Assets"
 								   (list (cons 'type ACCT-TYPE-ASSET))
@@ -36,10 +35,10 @@
 	   (bank-account (cdr (assoc "Bank Account" accounts)))
 	   (wallet (cdr (assoc "Wallet" accounts))))
 
-      (env-create-daily-transactions env start-date-tp end-date-tp bank-account wallet)
-      (format #t "Created transactions for each day from ~a to ~a~%" (gnc-ctime (gnc:timepair->secs start-date-tp)) (gnc-ctime (gnc:timepair->secs end-date-tp)))
+      (env-create-daily-transactions env start-date end-date bank-account wallet)
+      (format #t "Created transactions for each day from ~a to ~a~%" (gnc-ctime start-date) (gnc-ctime end-date))
       (let ((splits (gnc:account-get-trans-type-splits-interval (list bank-account wallet)
 							      ACCT-TYPE-ASSET
-							      q-start-date-tp q-end-date-tp)))
+							      q-start-date q-end-date)))
 	;; 10 is the right number (5 days, two splits per tx)
 	(or (equal? 10 (length splits)) (begin (format #t "Fail, ~d splits, expected 10~%" (length splits)) #f))))))

commit e6f3abba30f5d4f0d497601a7aa3241de685918c
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue Dec 19 23:15:02 2017 +0800

    TP->T64: gnucash/report/report-system/html-acct-table

diff --git a/gnucash/report/report-system/html-acct-table.scm b/gnucash/report/report-system/html-acct-table.scm
index a9eed6a..cb8a387 100644
--- a/gnucash/report/report-system/html-acct-table.scm
+++ b/gnucash/report/report-system/html-acct-table.scm
@@ -129,14 +129,14 @@
 ;;         sorting function.  #f means to preform no sorting.  the
 ;;         default sorting function is gnc:account-code-less-p.
 ;; 
-;;     start-date: timepair
+;;     start-date: time64
 ;; 
 ;;         the starting date of the reporting period over which to
 ;;         report balances for this account.  if start-date is #f,
 ;;         will be no limit on how early a counted transaction may
 ;;         ocurr.
 ;; 
-;;     end-date: timepair
+;;     end-date: time64
 ;; 
 ;;         the ending date of the reporting period over which to
 ;;         report balances for this account.  if end-date is #f, there
@@ -1164,8 +1164,7 @@
 	  )
 	 )))
     (gnc:html-table-set-style! table "table" 'attribute(list "style" "width:100%; max-width:20em") 'attribute (list "cellpadding" "0"))
-    table)
-  )
+    table))
 
 ;; 
 ;; This function adds all the lines from a gnc:html-acct-table to a

commit 4d7e03b0edc4c81c7daca92509a1575d68bdc285
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri Nov 24 21:30:03 2017 +0800

    gnucash/report/report-system/collectors.scm - remove useless predicate type

diff --git a/gnucash/report/report-system/collectors.scm b/gnucash/report/report-system/collectors.scm
index 580ecba..28b9ee7 100644
--- a/gnucash/report/report-system/collectors.scm
+++ b/gnucash/report/report-system/collectors.scm
@@ -59,10 +59,6 @@
 (export slotset-check)
 (export slotset-map-input)
 
-(export predicate-and)
-(export predicate-or)
-(export predicate-not)
-
 (export binary-search-lt)
 
 ;; Filters
@@ -333,25 +329,6 @@
 			(car final))
 		      (make-list-collector (cons collector other-collectors))))
 
-;;
-;; Predicates
-;;
-;; Was thinking about turning these into a real type (just to get a
-;; decent predicate-name function).  Probably not required.
-
-(define (predicate-not p)
-  (lambda (x) (not (p x))))
-
-(define (predicate-and p1 p2)
-  (lambda (x) (and (p1 x) (p2 x))))
-
-(define (predicate-or p1 p2)
-  (lambda (x) (or (p1 x) (p2 x))))
-
-(define (make-predicate fn) fn)
-
-(define (predicate-test p value)
-  (p value))
 
 ;; Binary search. Returns highest index with content less than or
 ;; equal to the supplied value.

commit 8fc31ce53c57d12d2b88ba532f5e9b1e6f043604
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Jan 8 18:21:33 2018 +1100

    gnucash/report/report-system/report-collectors.scm

diff --git a/gnucash/report/report-system/report-collectors.scm b/gnucash/report/report-system/report-collectors.scm
index 78c9992..25d97c5 100644
--- a/gnucash/report/report-system/report-collectors.scm
+++ b/gnucash/report/report-system/report-collectors.scm
@@ -90,15 +90,15 @@
 
 (define (build-date-collector dates per-date-collector)
   (let* ((date-vector (list->vector dates))
-	 (slotset (make-slotset (lambda (split)
-				  (let* ((date (split->date split))
-					 (interval-index (binary-search-lt (lambda (pair date)
-									     (gnc:timepair-le (car pair) date))
-									   (cons date 0)
-									   date-vector))
-					 (interval (vector-ref date-vector interval-index)))
-				    interval))
-				dates)))
+         (slotset (make-slotset (lambda (split)
+                                  (let* ((date (split->date split))
+                                         (interval-index (binary-search-lt (lambda (pair date)
+                                                                             (<= (car pair) date))
+                                                                           date
+                                                                           date-vector))
+                                         (interval (vector-ref date-vector interval-index)))
+                                    interval))
+                                dates)))
     (collector-from-slotset slotset per-date-collector)))
 
 (define (build-category-by-account-collector account-destination-alist dates cell-accumulator result-collector)
@@ -131,16 +131,17 @@
 
 ;; Decide how to run the given report (but don't actually do any work)
 
-(define (category-by-account-report-work do-intervals? datepairs account-alist
-				    split-collector result-collector)
-  (let* ((dateinfo (if do-intervals? (category-report-dates-intervals datepairs)
-		       (category-report-dates-accumulate datepairs)))
-	 (processed-datepairs (third dateinfo))
-	 (splits-fn (lambda () (category-report-splits dateinfo account-alist)))
-	 (collector (collector-where (predicate-not split-closing?)
-				     (build-category-by-account-collector account-alist
-									  processed-datepairs split-collector
-									  result-collector))))
+(define (category-by-account-report-work do-intervals? dates account-alist
+                                         split-collector result-collector)
+  (let* ((dateinfo (if do-intervals? 
+                       (category-report-dates-intervals dates)
+                       (category-report-dates-accumulate dates)))
+         (processed-dates (third dateinfo))
+         (splits-fn (lambda () (category-report-splits dateinfo account-alist)))
+         (collector (collector-where (lambda (split) (not (split-closing? split)))
+                                     (build-category-by-account-collector account-alist
+                                                                          processed-dates split-collector
+                                                                          result-collector))))
     (cons splits-fn collector)))
 
 (define (category-report-splits dateinfo account-alist)
@@ -148,19 +149,19 @@
 	(max-date (second dateinfo)))
     (splits-up-to (map car account-alist) min-date max-date)))
 
-(define (category-report-dates-intervals datepairs)
-  (let* ((min-date (car (list-min-max (map first datepairs) gnc:timepair-lt)))
-	 (max-date (cdr (list-min-max (map second datepairs) gnc:timepair-lt))))
-    (list min-date max-date datepairs)))
+(define (category-report-dates-intervals dates)
+  (let* ((min-date (car (list-min-max (map first dates) <)))
+         (max-date (cdr (list-min-max (map second dates) <))))
+    (list min-date max-date dates)))
 
 (define (category-report-dates-accumulate dates)
-  (let* ((min-date (gnc:secs->timepair 0))
-	 (max-date (cdr (list-min-max dates gnc:timepair-lt)))
-	 (datepairs (reverse! (cdr (fold (lambda (next acc)
-					   (let ((prev (car acc))
-						 (pairs-so-far (cdr acc)))
-					     (cons next (cons (list prev next) pairs-so-far))))
-					 (cons min-date '()) dates)))))
+  (let* ((min-date 0) ; fixme. 
+         (max-date (cdr (list-min-max dates <)))
+         (datepairs (reverse! (cdr (fold (lambda (next acc)
+                                           (let ((prev (car acc))
+                                                 (pairs-so-far (cdr acc)))
+                                             (cons next (cons (list prev next) pairs-so-far))))
+                                         (cons min-date '()) dates)))))
     (list min-date max-date datepairs)))
 
 

commit a0d61b4f623f3273c98900cccb556e5634a24faf
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Jan 8 18:21:23 2018 +1100

    gnucash/report/report-system/commodity-utilities.scm

diff --git a/gnucash/report/report-system/commodity-utilities.scm b/gnucash/report/report-system/commodity-utilities.scm
index 3ff6c4e..8d3b3cf 100644
--- a/gnucash/report/report-system/commodity-utilities.scm
+++ b/gnucash/report/report-system/commodity-utilities.scm
@@ -35,11 +35,11 @@
 
 
 ;; Returns a list of all splits in the 'currency-accounts' up to
-;; 'end-date-tp' which have two different commodities involved, one of
+;; 'end-date' which have two different commodities involved, one of
 ;; which is equivalent to 'commodity' (the latter constraint only if
 ;; 'commodity' != #f ).
 (define (gnc:get-match-commodity-splits
-         currency-accounts end-date-tp commodity)
+         currency-accounts end-date commodity)
   (let ((query (qof-query-create-for-splits))
         (splits #f))
 
@@ -48,8 +48,8 @@
     (xaccQueryAddAccountMatch query
                               currency-accounts
                               QOF-GUID-MATCH-ANY QOF-QUERY-AND)
-    (xaccQueryAddDateMatchTS
-     query #f end-date-tp #t end-date-tp QOF-QUERY-AND)
+    (xaccQueryAddDateMatchTT
+     query #f end-date #t end-date QOF-QUERY-AND)
 
     ;; Get the query result, i.e. all splits in currency
     ;; accounts.
@@ -89,23 +89,22 @@
     splits))
 
 ;; Returns a sorted list of all splits in the 'currency-accounts' up
-;; to 'end-date-tp' which have the 'commodity' and one other commodity
+;; to 'end-date' which have the 'commodity' and one other commodity
 ;; involved. The splits are sorted by date.
 (define (gnc:get-match-commodity-splits-sorted currency-accounts
-                                               end-date-tp
+                                               end-date
                                                commodity)
   (sort (gnc:get-match-commodity-splits currency-accounts
-                                        end-date-tp commodity)
+                                        end-date commodity)
         (lambda (a b)
-          (gnc:timepair-lt
-           (gnc-transaction-get-date-posted (xaccSplitGetParent a))
-           (gnc-transaction-get-date-posted (xaccSplitGetParent b))))))
+          (< (xaccTransGetDate (xaccSplitGetParent a))
+             (xaccTransGetDate (xaccSplitGetParent b))))))
 
 
 ;; Returns a list of all splits in the currency-accounts up to
 ;; end-date which have two *different* commodities involved.
-(define (gnc:get-all-commodity-splits currency-accounts end-date-tp)
-  (gnc:get-match-commodity-splits currency-accounts end-date-tp #f))
+(define (gnc:get-all-commodity-splits currency-accounts end-date)
+  (gnc:get-match-commodity-splits currency-accounts end-date #f))
 
 
 
@@ -131,11 +130,11 @@
 
 ;; Create a list of all prices of 'price-commodity' measured in the
 ;; currency 'report-currency'. The prices are taken from all splits in
-;; 'currency-accounts' up until the date 'end-date-tp'. Returns a list
+;; 'currency-accounts' up until the date 'end-date'. Returns a list
 ;; of lists. Each listelement looks like the list (time price), where
-;; 'time' is the timepair when the <gnc:numeric*> 'price' was valid.
+;; 'time' is the time64 when the <gnc:numeric*> 'price' was valid.
 (define (gnc:get-commodity-totalavg-prices
-         currency-accounts end-date-tp price-commodity report-currency)
+         currency-accounts end-date price-commodity report-currency)
   (let ((total-foreign (gnc-numeric-zero))
         (total-domestic (gnc-numeric-zero)))
     (filter
@@ -150,7 +149,7 @@
                               (xaccSplitGetAmount a)))
                (value-amount (gnc-numeric-abs
                               (xaccSplitGetValue a)))
-               (transaction-date (gnc-transaction-get-date-posted
+               (transaction-date (xaccTransGetDate
                                   (xaccSplitGetParent a)))
                (foreignlist
                 (if (gnc-commodity-equiv transaction-comm
@@ -213,7 +212,7 @@
       ;; date.
       (gnc:get-match-commodity-splits-sorted
        currency-accounts
-       end-date-tp price-commodity)))))
+       end-date price-commodity)))))
 
 ;; Create a list of prices for all commodities in 'commodity-list',
 ;; i.e. the same thing as in get-commodity-totalavg-prices but
@@ -221,7 +220,7 @@
 ;; of the foreign-currency and the appropriate list from
 ;; gnc:get-commodity-totalavg-prices, see there.
 (define (gnc:get-commoditylist-totalavg-prices
-         commodity-list report-currency end-date-tp
+         commodity-list report-currency end-date
          start-percent delta-percent)
   (let ((currency-accounts
          ;;(filter gnc:account-has-shares?
@@ -238,17 +237,17 @@
               (+ start-percent (* delta-percent (/ work-done work-to-do)))))
          (cons c
                (gnc:get-commodity-totalavg-prices
-                currency-accounts end-date-tp c report-currency))))
+                currency-accounts end-date c report-currency))))
      commodity-list)))
 
 ;; Get the instantaneous prices for the 'price-commodity', measured in
 ;; amounts of the 'report-currency'. The prices are taken from all
 ;; splits in 'currency-accounts' up until the date
-;; 'end-date-tp'. Returns a list of lists. Each listelement looks like
-;; the list (time price), where 'time' is the timepair when the
+;; 'end-date'. Returns a list of lists. Each listelement looks like
+;; the list (time price), where 'time' is the time64 when the
 ;; <gnc:numeric*> 'price' was valid.
 (define (gnc:get-commodity-inst-prices
-         currency-accounts end-date-tp price-commodity report-currency)
+         currency-accounts end-date price-commodity report-currency)
   ;; go through all splits; convert all splits into a price.
   (filter
    gnc:price-is-not-zero?
@@ -262,7 +261,7 @@
                             (xaccSplitGetAmount a)))
              (value-amount (gnc-numeric-abs
                             (xaccSplitGetValue a)))
-             (transaction-date (gnc-transaction-get-date-posted
+             (transaction-date (xaccTransGetDate
                                 (xaccSplitGetParent a)))
              (foreignlist
               (if (gnc-commodity-equiv transaction-comm price-commodity)
@@ -314,7 +313,7 @@
     ;; Get all the interesting splits, sorted by date.
     (gnc:get-match-commodity-splits-sorted
      currency-accounts
-     end-date-tp price-commodity))))
+     end-date price-commodity))))
 
 ;; Get the instantaneous prices for all commodities in
 ;; 'commodity-list', i.e. the same thing as get-commodity-inst-prices
@@ -322,7 +321,7 @@
 ;; consists of the foreign-currency and the appropriate list from
 ;; gnc:get-commodity-inst-prices, see there.
 (define (gnc:get-commoditylist-inst-prices
-         commodity-list report-currency end-date-tp
+         commodity-list report-currency end-date
          start-percent delta-percent)
   (let ((currency-accounts
          ;;(filter gnc:account-has-shares?
@@ -339,7 +338,7 @@
               (+ start-percent (* delta-percent (/ work-done work-to-do)))))
          (cons c
                (gnc:get-commodity-inst-prices
-                currency-accounts end-date-tp c report-currency))))
+                currency-accounts end-date c report-currency))))
      commodity-list)))
 
 
@@ -350,26 +349,26 @@
 (define (gnc:pricelist-price-find-nearest
          pricelist date)
   (let* ((later (find (lambda (p)
-                        (gnc:timepair-lt date (first p)))
+                        (< date (first p)))
                       pricelist))
          (earlierlist (take-while
                        (lambda (p)
-                         (gnc:timepair-ge date (first p)))
+                         (>= date (first p)))
                        pricelist))
          (earlier (and (not (null? earlierlist))
                        (last earlierlist))))
     ;;          (if earlier
     ;;              (warn "earlier"
-    ;;                    (gnc-print-date (first earlier))
+    ;;                    (qof-print-date (first earlier))
     ;;                    (gnc-numeric-to-double (second earlier))))
     ;;          (if later
     ;;              (warn "later"
-    ;;                    (gnc-print-date (first later))
+    ;;                    (qof-print-date (first later))
     ;;                    (gnc-numeric-to-double (second later))))
 
     (if (and earlier later)
-        (if (< (abs (gnc:timepair-delta date (first earlier)))
-               (abs (gnc:timepair-delta date (first later))))
+        (if (< (abs (- (first earlier) date))
+               (abs (- (first later) date)))
             (second earlier)
             (second later))
         (or
@@ -827,7 +826,7 @@
             (gnc-pricedb-get-db (gnc-get-current-book))
             (gnc:gnc-monetary-amount foreign)
             (gnc:gnc-monetary-commodity foreign)
-            domestic (timespecCanonicalDayTime date))))
+            domestic (time64CanonicalDayTime date))))
       #f))
 
 ;; Exchange by the nearest price from pricelist. This function takes
@@ -868,18 +867,18 @@
 ;; the value of 'source-option', whose possible values are set in
 ;; gnc:options-add-price-source!.
 (define (gnc:case-exchange-fn
-         source-option report-currency to-date-tp)
+         source-option report-currency to-date)
   (case source-option
     ((average-cost) (gnc:make-exchange-function
                      (gnc:make-exchange-alist
-                      report-currency to-date-tp #t)))
+                      report-currency to-date #t)))
     ((weighted-average) (gnc:make-exchange-function
                          (gnc:make-exchange-alist
-                          report-currency to-date-tp #f)))
+                          report-currency to-date #f)))
     ((pricedb-latest) gnc:exchange-by-pricedb-latest)
     ((pricedb-nearest) (lambda (foreign domestic)
                          (gnc:exchange-by-pricedb-nearest
-                          foreign domestic to-date-tp)))
+                          foreign domestic to-date)))
     (else
      (begin
        ;; FIX-ME
@@ -892,7 +891,7 @@
                  source-option " using pricedb-nearest.")
        (lambda (foreign domestic)
          (gnc:exchange-by-pricedb-nearest
-          foreign domestic to-date-tp))))))
+          foreign domestic to-date))))))
 
 ;; Return a ready-to-use function. Which one to use is determined by
 ;; the value of 'source-option', whose possible values are set in
@@ -902,25 +901,25 @@
 ;; section of the progress bar while running this function.
 ;;
 (define (gnc:case-exchange-time-fn
-         source-option report-currency commodity-list to-date-tp
+         source-option report-currency commodity-list to-date
          start-percent delta-percent)
   (case source-option
     ;; Make this the same as gnc:case-exchange-fn
     ((average-cost) (let* ((exchange-fn (gnc:make-exchange-function
                                          (gnc:make-exchange-alist
-                                          report-currency to-date-tp #t))))
+                                          report-currency to-date #t))))
                       (lambda (foreign domestic date)
                         (exchange-fn foreign domestic))))
     ((weighted-average) (let ((pricealist
                                (gnc:get-commoditylist-totalavg-prices
-                                commodity-list report-currency to-date-tp
+                                commodity-list report-currency to-date
                                 start-percent delta-percent)))
                           (lambda (foreign domestic date)
                             (gnc:exchange-by-pricealist-nearest
                              pricealist foreign domestic date))))
     ((actual-transactions) (let ((pricealist
                                   (gnc:get-commoditylist-inst-prices
-                                   commodity-list report-currency to-date-tp)))
+                                   commodity-list report-currency to-date)))
                              (lambda (foreign domestic date)
                                (gnc:exchange-by-pricealist-nearest
                                 pricealist foreign domestic date))))
@@ -933,8 +932,7 @@
                  source-option ". Using pricedb-nearest.")
        ;; FIX-ME another hack to prevent report crashing when an
        ;; unimplemented source-option comes through
-       gnc:exchange-by-pricedb-nearest
-       ))))
+       gnc:exchange-by-pricedb-nearest))))
 
 
 
@@ -972,15 +970,10 @@
                             ;; returns #f instead of an actual
                             ;; <gnc:monetary>.  Better to just return #f.
                             (exchange-fn (gnc:make-gnc-monetary curr val)
-                                         domestic))
-                           )
-                  )
-              )
+                                         domestic)))))
             #f)
            (balance 'getmonetary domestic #f)))
-        (else #f)
-        )
-  )
+        (else #f)))
 
 ;; As above, but adds only the commodities of other stocks and
 ;; mutual-funds. Returns a commodity-collector, (not a <gnc:monetary>)
@@ -1019,13 +1012,8 @@
 (define (gnc:uniform-commodity? amt report-commodity)
   ;; function to see if the commodity-collector amt
   ;; contains any foreign commodities
-  (let ((elts (gnc-commodity-collector-commodity-count amt))
-        )
+  (let ((elts (gnc-commodity-collector-commodity-count amt)))
     (or (equal? elts 0)
         (and (equal? elts 1)
              (gnc-commodity-collector-contains-commodity?
-              amt report-commodity)
-             )
-        )
-    )
-  )
+              amt report-commodity)))))

commit c20c8eded0e6bd782a83324f399ca53add5b00a1
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue Dec 19 23:11:24 2017 +0800

    TP->T64: gnucash/report/report-system/report-utilities

diff --git a/gnucash/report/report-system/report-utilities.scm b/gnucash/report/report-system/report-utilities.scm
index 462dd0e..a2ba5eb 100644
--- a/gnucash/report/report-system/report-utilities.scm
+++ b/gnucash/report/report-system/report-utilities.scm
@@ -489,7 +489,7 @@
 
       (qof-query-set-book query (gnc-get-current-book))
       (xaccQueryAddSingleAccountMatch query account QOF-QUERY-AND)
-      (xaccQueryAddDateMatchTS query #f date #t date QOF-QUERY-AND)
+      (xaccQueryAddDateMatchTT query #f date #t date QOF-QUERY-AND)
       (qof-query-set-sort-order query
 				(list SPLIT-TRANS TRANS-DATE-POSTED)
 				(list QUERY-DEFAULT-SORT)
@@ -529,9 +529,9 @@
     ;; Build a query to find all splits between the indicated dates.
     (qof-query-set-book query (gnc-get-current-book))
     (xaccQueryAddSingleAccountMatch query account QOF-QUERY-AND)
-    (xaccQueryAddDateMatchTS query
-                             (and start-date #t) start-date
-                             (and end-date #t) end-date
+    (xaccQueryAddDateMatchTT query
+                             (and start-date #t) (if start-date start-date 0)
+                             (and end-date #t) (if end-date end-date 0)
                              QOF-QUERY-AND)
 
     ;; Get the query results.
@@ -718,14 +718,13 @@
 ;; the type is an alist '((str "match me") (cased #f) (regexp #f))
 ;; If type is #f, sums all non-closing splits in the interval
 (define (gnc:account-get-trans-type-balance-interval
-	 account-list type start-date-tp end-date-tp)
+	 account-list type start-date end-date)
   (let* ((total (gnc:make-commodity-collector)))
     (map (lambda (split)
            (let* ((shares (xaccSplitGetAmount split))
                   (acct-comm (xaccAccountGetCommodity
                               (xaccSplitGetAccount split)))
-                  (txn (xaccSplitGetParent split))
-                  )
+                  (txn (xaccSplitGetParent split)))
              (if type 
                 (gnc-commodity-collector-add total acct-comm shares)
                 (if (not (xaccTransGetIsClosingTxn txn))
@@ -733,7 +732,7 @@
              )))
            )
 	 (gnc:account-get-trans-type-splits-interval
-          account-list type start-date-tp end-date-tp)
+          account-list type start-date end-date)
 	 )
     total
     )
@@ -743,7 +742,7 @@
 ;; the type is an alist '((str "match me") (cased #f) (regexp #f))
 ;; If type is #f, sums all splits in the interval (even closing splits)
 (define (gnc:account-get-trans-type-balance-interval-with-closing
-	 account-list type start-date-tp end-date-tp)
+	 account-list type start-date end-date)
   (let* ((total (gnc:make-commodity-collector)))
     (map (lambda (split)
            (let* ((shares (xaccSplitGetAmount split))
@@ -754,7 +753,7 @@
              )
            )
 	 (gnc:account-get-trans-type-splits-interval
-          account-list type start-date-tp end-date-tp)
+          account-list type start-date end-date)
 	 )
     total
     )
@@ -763,7 +762,7 @@
 ;; Filters the splits from the source to the target accounts
 ;; returns a commodity collector
 ;; does NOT do currency exchanges
-(define (gnc:account-get-total-flow direction target-account-list from-date-tp to-date-tp)
+(define (gnc:account-get-total-flow direction target-account-list from-date to-date)
 
   (let* (
           (total-flow (gnc:make-commodity-collector))
@@ -784,11 +783,11 @@
             ;; ----------------------------------------------------
             (let* (
                     (transaction (xaccSplitGetParent target-account-split))
-                    (transaction-date-posted (gnc-transaction-get-date-posted transaction))
+                    (transaction-date-posted (xaccTransGetDate transaction))
                   )
               (if (and
-                    (gnc:timepair-le transaction-date-posted to-date-tp)
-                    (gnc:timepair-ge transaction-date-posted from-date-tp)
+                    (<= transaction-date-posted to-date)
+                    (>= transaction-date-posted from-date)
                   )
                 ;; -------------------------------------------------------------
                 ;; get the split information
@@ -830,7 +829,7 @@
 ;; similar, but only counts transactions with non-negative shares and
 ;; *ignores* any closing entries
 (define (gnc:account-get-pos-trans-total-interval
-	 account-list type start-date-tp end-date-tp)
+	 account-list type start-date end-date)
   (let* ((str-query (qof-query-create-for-splits))
 	 (sign-query (qof-query-create-for-splits))
 	 (total-query #f)
@@ -850,14 +849,16 @@
     (gnc:query-set-match-non-voids-only! sign-query (gnc-get-current-book))
     (xaccQueryAddAccountMatch str-query account-list QOF-GUID-MATCH-ANY QOF-QUERY-AND)
     (xaccQueryAddAccountMatch sign-query account-list QOF-GUID-MATCH-ANY QOF-QUERY-AND)
-    (xaccQueryAddDateMatchTS
+    (xaccQueryAddDateMatchTT
      str-query
-     (and start-date-tp #t) start-date-tp
-     (and end-date-tp #t) end-date-tp QOF-QUERY-AND)
-    (xaccQueryAddDateMatchTS
+     (and start-date #t) (if start-date start-date 0)
+     (and end-date #t) (if end-date end-date 0)
+     QOF-QUERY-AND)
+    (xaccQueryAddDateMatchTT
      sign-query
-     (and start-date-tp #t) start-date-tp
-     (and end-date-tp #t) end-date-tp QOF-QUERY-AND)
+     (and start-date #t) (if start-date start-date 0)
+     (and end-date #t) (if end-date end-date 0)
+     QOF-QUERY-AND)
     (xaccQueryAddDescriptionMatch
      str-query matchstr case-sens regexp QOF-COMPARE-CONTAINS QOF-QUERY-AND)
     (set! total-query
@@ -885,9 +886,7 @@
          splits
          )
     (qof-query-destroy total-query)
-    total
-    )
-  )
+    total))
 
 ;; Return the splits that match an account list, date range, and (optionally) type
 ;; where type is defined as an alist like:
@@ -898,7 +897,7 @@
 ;; only non-closing transactions will be returned, and if it is omitted then both
 ;; kinds of transactions will be returned.
 (define (gnc:account-get-trans-type-splits-interval
-         account-list type start-date-tp end-date-tp)
+         account-list type start-date end-date)
   (if (null? account-list)
       ;; No accounts given. Return empty list.
       '()
@@ -917,10 +916,11 @@
     (qof-query-set-book query (gnc-get-current-book))
     (gnc:query-set-match-non-voids-only! query (gnc-get-current-book))
     (xaccQueryAddAccountMatch query account-list QOF-GUID-MATCH-ANY QOF-QUERY-AND)
-    (xaccQueryAddDateMatchTS
+    (xaccQueryAddDateMatchTT
      query
-     (and start-date-tp #t) start-date-tp
-     (and end-date-tp #t) end-date-tp QOF-QUERY-AND)
+     (and start-date #t) (if start-date start-date 0)
+     (and end-date #t) (if end-date end-date 0)
+     QOF-QUERY-AND)
     (if (or matchstr closing) 
          (begin
            (set! query2 (qof-query-create-for-splits))

commit b53aa85660859c8df6e8bae094e2b2d2356c9985
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Dec 17 17:19:57 2017 +0800

    TP->T64: libgnucash/engine/test/test-extras.scm

diff --git a/libgnucash/engine/test/test-extras.scm b/libgnucash/engine/test/test-extras.scm
index faf6508..a8f0519 100644
--- a/libgnucash/engine/test/test-extras.scm
+++ b/libgnucash/engine/test/test-extras.scm
@@ -138,15 +138,15 @@
   (let ((txn (xaccMallocTransaction (gnc-get-current-book)))
 	(split-1 (xaccMallocSplit  (gnc-get-current-book)))
 	(split-2 (xaccMallocSplit  (gnc-get-current-book)))
-	(gnc-localtime (gnc:timepair->date date)))
+	(datevec (gnc-localtime date)))
     (with-transaction txn
 		      (lambda ()
 			(xaccTransSetDescription txn (env-string env "ponies"))
 			(xaccTransSetCurrency txn (gnc-default-report-currency))
 			(xaccTransSetDate txn
-					  (gnc:date-get-month-day gnc-localtime)
-					  (gnc:date-get-month gnc-localtime)
-					  (gnc:date-get-year gnc-localtime))
+					  (gnc:date-get-month-day datevec)
+					  (gnc:date-get-month datevec)
+					  (gnc:date-get-year datevec))
 			(xaccSplitSetParent split-1 txn)
 			(xaccSplitSetParent split-2 txn)
 			(xaccSplitSetAccount split-1 credit)
@@ -184,8 +184,8 @@
 		  (env-create-transaction env date to-account
 					  from-account
 					  (/
-                                           (gnc:date-get-month-day (gnc:timepair->date date))
-                                           1)))
+					   (gnc:date-get-month-day (gnc-localtime date))
+					   1)))
 		(cdr (reverse dates-this-month)))))
 
 (define (env-create-account-structure env account-structure)

commit d41ad85f0a7e45ff163d1ecedc441128bfac0ab6
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue Dec 19 23:10:29 2017 +0800

    TP->T64 COMPATIBILITY SHIM: gnucash/libgnucash/app-utils/options.scm
    
    This commit adds a compatibiliy shim. Although the rest of gnucash
    can be converted to time64, this shim allows a Gnucash session to
    load reports saved with timepairs.

diff --git a/libgnucash/app-utils/options.scm b/libgnucash/app-utils/options.scm
index 6083a14..b6c4f96 100644
--- a/libgnucash/app-utils/options.scm
+++ b/libgnucash/app-utils/options.scm
@@ -562,13 +562,24 @@
          subtype
          relative-date-list)
   (define (date-legal date)
-    (and (pair? date) 
-         (or 
+    (and (pair? date)
+         (or
           (and (eq? 'relative (car date)) (symbol? (cdr date)))
-          (and (eq? 'absolute (car date)) 
-               (pair? (cdr date)) 
-               (exact? (cadr date)) 
-               (exact? (cddr date))))))
+          (and (eq? 'absolute (car date))
+               (or (and (pair? (cdr date))   ; we can still accept
+                        (exact? (cadr date)) ; old-style timepairs
+                        (exact? (cddr date)))
+                   (and (number? (cdr date))
+                        (exact? (cdr date))))))))
+  (define (maybe-convert-to-time64 date)
+    ;; compatibility shim. this is triggered only when date is type
+    ;; (cons 'absolute (cons sec nsec)) - we'll convert to
+    ;; (cons 'absolute sec). this shim must always be kept for gnucash
+    ;; to reload saved reports, or reload reports launched at startup,
+    ;; which had been saved as timepairs.
+    (if (pair? (cdr date))
+        (cons (car date) (cadr date))
+        date))
   (define (list-lookup list item)
     (cond
      ((null? list) #f)
@@ -582,7 +593,7 @@
      (lambda () value)
      (lambda (date)
        (if (date-legal date)
-           (set! value date)
+           (set! value (maybe-convert-to-time64 date))
            (gnc:error "Illegal date value set:" date)))
      default-getter
      (gnc:restore-form-generator value->string)

commit 7550ccf537c812c001bf0db1eb7604b9a373f488
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Thu Dec 21 19:55:38 2017 +0800

    date-utilities.scm: optimize leapyear calc

diff --git a/libgnucash/app-utils/date-utilities.scm b/libgnucash/app-utils/date-utilities.scm
index 008e141..5df5c9a 100644
--- a/libgnucash/app-utils/date-utilities.scm
+++ b/libgnucash/app-utils/date-utilities.scm
@@ -159,11 +159,9 @@
 
 ;; is leap year?
 (define (gnc:leap-year? year)
-  (if (= (remainder year 4) 0)
-      (if (= (remainder year 100) 0)
-	  (if (= (remainder year 400) 0) #t #f)
-	  #t)
-      #f))
+  (or (and (zero? (remainder year 4))
+           (not (zero? (remainder year 100))))
+      (zero? (remainder year 400))))
 
 ;; number of days in year
 (define (gnc:days-in-year year)

commit 33a7bb73db33efe1c5c9d80835cd628fba82402f
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Nov 19 05:20:35 2017 +0800

    Bugzilla 790526 Correct weeknum calculator
    
    This change will fix 'num-of-weeks-since-1/jan/1970' which formerly used quotient to remove
    the fractional part of the division. For negative values of num-of-weeks, the number is truncated
    in the wrong direction (i.e. towards 0). This change uses floor instead to ensure the num-of-weeks
    found is the nearest integer LESS than the fractional number.

diff --git a/libgnucash/app-utils/date-utilities.scm b/libgnucash/app-utils/date-utilities.scm
index 813c3fe..008e141 100644
--- a/libgnucash/app-utils/date-utilities.scm
+++ b/libgnucash/app-utils/date-utilities.scm
@@ -64,9 +64,8 @@
   (+ (tm:wday datevec) 1))
 ;; jan 1 == 1
 (define (gnc:date-get-week datevec)
-  (gnc:date-to-week (gnc:timepair->secs
-		     (gnc:timepair-start-day-time
-		      (gnc:date->timepair datevec)))))
+  (gnc:date-to-week (gnc:time64-start-day-time
+                     (gnc-mktime datevec))))
 
 (define (gnc:date-get-year-day datevec)
   (+ (tm:yday datevec) 1))
@@ -235,7 +234,7 @@
   (/ (- (/ (/ caltime 3600.0) 24) 3) 7))
 
 (define (gnc:date-to-week caltime)
-  (quotient (- (quotient caltime 86400) 3) 7))
+  (floor (/ (- (/ caltime 86400) 3) 7)))
 
 ;; convert a date in seconds since 1970 into # of days since Feb 28, 1970
 ;; ignoring leap-seconds

commit 335165104bbfc0f7f6e8352220d32ea28d64548c
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Dec 23 15:45:00 2017 +0800

    ADD-TIME64-API: libgnucash/app-utils/app-utils.scm & date-utilities.scm

diff --git a/libgnucash/app-utils/app-utils.scm b/libgnucash/app-utils/app-utils.scm
index cc21aa2..0ada8b5 100644
--- a/libgnucash/app-utils/app-utils.scm
+++ b/libgnucash/app-utils/app-utils.scm
@@ -199,6 +199,13 @@
 (export gnc:timepair-get-week-day)
 (export gnc:timepair-get-week)
 (export gnc:timepair-get-year-day)
+(export gnc:time64-get-year)
+(export gnc:time64-get-quarter)
+(export gnc:time64-get-month-day)
+(export gnc:time64-get-month)
+(export gnc:time64-get-week-day)
+(export gnc:time64-get-week)
+(export gnc:time64-get-year-day)
 (export gnc:date-get-year-string)
 (export gnc:date-get-quarter-string)
 (export gnc:date-get-quarter-year-string)
@@ -218,6 +225,8 @@
 (export moddatek)
 (export decdate)
 (export incdate)
+(export decdate64)
+(export incdate64)
 (export gnc:timepair-later)
 (export gnc:timepair-lt)
 (export gnc:timepair-earlier)
@@ -230,6 +239,8 @@
 (export gnc:timepair-le-date)
 (export gnc:timepair-ge-date)
 (export gnc:timepair-eq-date)
+(export gnc:time64-le-date)
+(export gnc:time64-ge-date)
 (export gnc:make-date-interval-list)
 (export gnc:make-date-list)
 (export make-zdate)
@@ -250,6 +261,10 @@
 (export gnc:timepair-end-day-time)
 (export gnc:timepair-previous-day)
 (export gnc:timepair-next-day)
+(export gnc:time64-start-day-time)
+(export gnc:time64-end-day-time)
+(export gnc:time64-previous-day)
+(export gnc:time64-next-day)
 (export gnc:reldate-get-symbol)
 (export gnc:reldate-get-string)
 (export gnc:reldate-get-desc)
diff --git a/libgnucash/app-utils/date-utilities.scm b/libgnucash/app-utils/date-utilities.scm
index 1bba52f..813c3fe 100644
--- a/libgnucash/app-utils/date-utilities.scm
+++ b/libgnucash/app-utils/date-utilities.scm
@@ -20,6 +20,7 @@
 ;; 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
 ;; Boston, MA  02110-1301,  USA       gnu at gnu.org
 
+
 (use-modules (gnucash core-utils)
              (gnucash printf)
              (gnucash gettext))
@@ -27,20 +28,25 @@
 (define gnc:reldate-list '())
 
 (define (gnc:timepair->secs tp)
+  (gnc:warn "deprecated timepair->secs, use time64 directly")
   (inexact->exact 
    (+ (car tp)
       (/ (cdr tp) 1000000000))))
 
 (define (gnc:secs->timepair secs)
+  (gnc:warn "deprecated secs->timepair, use time64 direclty")
   (cons secs 0))
 
 (define (gnc:timepair->date tp)
+  (gnc:warn "deprecated timepair->date, use gnc-localtime")
   (gnc-localtime (gnc:timepair->secs tp)))
 
 (define (gnc:date->timepair date)
+  (gnc:warn "deprecated timepair->date, use gnc-mktime")
   (gnc:secs->timepair (gnc-mktime date)))
 
 (define (gnc:timepair? date)
+  (gnc:warn "deprecated timepair?")
   (and (number? (car date))
        (number? (cdr date))))
 
@@ -66,26 +72,54 @@
   (+ (tm:yday datevec) 1))
 
 (define (gnc:timepair-get-year tp)
+  (gnc:warn "deprecated timepair-get-year")
   (gnc:date-get-year (gnc:timepair->date tp)))
 
 (define (gnc:timepair-get-quarter tp)
+  (gnc:warn "deprecated timepair-get-quarter")
   (gnc:date-get-quarter (gnc:timepair->date tp)))
 
 (define (gnc:timepair-get-month-day tp)
+  (gnc:warn "deprecated timepair-get-month-day")
   (gnc:date-get-month-day (gnc:timepair->date tp)))
 
 (define (gnc:timepair-get-month tp)
+  (gnc:warn "deprecated timepair-get-month")
   (gnc:date-get-month (gnc:timepair->date tp)))
 
 (define (gnc:timepair-get-week-day tp)
+  (gnc:warn "deprecated timepair-get-week-day")
   (gnc:date-get-week-day (gnc:timepair->date tp)))
 
 (define (gnc:timepair-get-week tp)
+  (gnc:warn "deprecated timepair-get-week")
   (gnc:date-get-week (gnc:timepair->date tp)))
 
 (define (gnc:timepair-get-year-day tp)
+  (gnc:warn "deprecated timepair-get-year-day")
   (gnc:date-get-year-day (gnc:timepair->date tp)))
 
+(define (gnc:time64-get-year t64)
+  (gnc:date-get-year (gnc-localtime t64)))
+
+(define (gnc:time64-get-quarter t64)
+  (gnc:date-get-quarter (gnc-localtime t64)))
+
+(define (gnc:time64-get-month-day t64)
+  (gnc:date-get-month-day (gnc-localtime t64)))
+
+(define (gnc:time64-get-month t64)
+  (gnc:date-get-month (gnc-localtime t64)))
+
+(define (gnc:time64-get-week-day t64)
+  (gnc:date-get-week-day (gnc-localtime t64)))
+
+(define (gnc:time64-get-week t64)
+  (gnc:date-get-week (gnc-localtime t64)))
+
+(define (gnc:time64-get-year-day t64)
+  (gnc:date-get-year-day (gnc-localtime t64)))
+
 (define (gnc:date-get-year-string datevec)
   (gnc-locale-to-utf8 (strftime "%Y" datevec)))
 
@@ -105,21 +139,24 @@
   (gnc-locale-to-utf8 (strftime "%B %Y" datevec)))
 
 (define (gnc:date-get-week-year-string datevec)
-  (let ((begin-string (gnc-print-date
-		       (gnc:secs->timepair
-			(+ (* (gnc:date-to-week
-			    (gnc:timepair->secs
-			     (gnc:timepair-start-day-time
-			      (gnc:date->timepair datevec))))
-			   604800 ) 345600))))
-        (end-string (gnc-print-date
-		       (gnc:secs->timepair
-			(+ (* (gnc:date-to-week
-			    (gnc:timepair->secs
-			     (gnc:timepair-start-day-time
-			      (gnc:date->timepair datevec))))
-			   604800 ) 864000)))))
-  (sprintf #f (_ "%s to %s") begin-string end-string)))
+  (let* ((beginweekt64 (* (gnc:time64-get-week
+                            (gnc-mktime datevec))
+                          604800))
+         (begin-string (qof-print-date (+ beginweekt64 345600)))
+         (end-string (qof-print-date (+ beginweekt64 864000))))
+    (sprintf #f (_ "%s to %s") begin-string end-string)))
+    
+;  (let ((begin-string (qof-print-date
+;                       (+ (* (gnc:date-get-week
+;                              (gnc:time64-start-day-time
+;                               (gnc-mktime datevec)))
+;                             604800) 345600)))
+;        (end-string (qof-print-date
+;                     (+ (* (gnc:date-get-week
+;                            (gnc:time64-start-day-time
+;                             (gnc-mktime datevec)))
+;                           604800) 864000))))
+;    (sprintf #f (_ "%s to %s") begin-string end-string)))
 
 ;; is leap year?
 (define (gnc:leap-year? year)
@@ -221,6 +258,7 @@
 
 ;; Modify a date
 (define (moddate op adate delta)
+  (gnc:warn "deprecated moddate. use moddate64 instead.")
   (let ((newtm (gnc:timepair->date adate)))
     (begin
       (set-tm:sec newtm (op (tm:sec newtm) (tm:sec delta)))
@@ -232,36 +270,60 @@
       (set-tm:isdst newtm 0)
       (gnc:date->timepair newtm))))
 
+(define (moddate64 op adate delta)
+  (let ((newtm (gnc-localtime adate)))
+    (begin
+      (set-tm:sec newtm (op (tm:sec newtm) (tm:sec delta)))
+      (set-tm:min newtm (op (tm:min newtm) (tm:min delta)))
+      (set-tm:hour newtm (op (tm:hour newtm) (tm:hour delta)))
+      (set-tm:mday newtm (op (tm:mday newtm) (tm:mday delta)))
+      (set-tm:mon newtm (op (tm:mon newtm) (tm:mon delta)))
+      (set-tm:year newtm (op (tm:year newtm) (tm:year delta)))
+      (set-tm:isdst newtm -1)
+      (gnc-mktime newtm))))
+
 ;; Add or subtract time from a date
 (define (decdate adate delta)(moddate - adate delta ))
 (define (incdate adate delta)(moddate + adate delta ))
 
+(define (decdate64 adate delta) (moddate64 - adate delta ))
+(define (incdate64 adate delta) (moddate64 + adate delta ))
+
 ;; Time comparison, true if t2 is later than t1
 ;; FIXME: RENAME THIS FUNCTION!!!!
+;; NOTE ALL THESE FUNCTIONS WILL BECOME OBSOLETE SOON
 
 (define (gnc:timepair-later t1 t2)
+  (gnc:warn "deprecated timepair-later")
   (cond ((< (car t1) (car t2)) #t)
         ((= (car t1) (car t2)) (< (cdr t2) (cdr t2)))
         (else #f)))
 
-(define gnc:timepair-lt gnc:timepair-later)
+(define (gnc:timepair-lt t1 t2)
+  (gnc:warn "deprecated timepair-lt")
+  (gnc:timepair-later t1 t2))
 
 (define (gnc:timepair-earlier t1 t2)
+  (gnc:warn "deprecated timepair-earlier")
   (gnc:timepair-later t2 t1))
 
 (define (gnc:timepair-gt t1 t2)
+  (gnc:warn "deprecated timepair-gt")
   (gnc:timepair-earlier t1 t2))
 
 ;; t1 <= t2
 (define (gnc:timepair-le t1 t2)
+  (gnc:warn "deprecated timepair-le")
   (cond ((< (car t1) (car t2)) #t)
         ((= (car t1) (car t2)) (<= (cdr t2) (cdr t2)))
         (else #f)))
 
 (define (gnc:timepair-ge t1 t2)
+  (gnc:warn "deprecated timepair-ge")
   (gnc:timepair-le t2 t1))
 
 (define (gnc:timepair-eq t1 t2)
+  (gnc:warn "deprecated timepair-eq")
   (and (= (car t1) (car t2)) (= (cdr t1) (cdr t2))))
 
 ;; date-granularity comparison functions.
@@ -274,22 +336,32 @@
   (gnc:timepair-earlier-date t2 t1))
 
 (define (gnc:timepair-le-date t1 t2)
+  (gnc:warn "deprecated gnc:timepair-le-date. use gnc:time64-le-date")
   (gnc:timepair-le (timespecCanonicalDayTime t1)
 		   (timespecCanonicalDayTime t2)))
 
 (define (gnc:timepair-ge-date t1 t2)
+  (gnc:warn "deprecated timepair-ge-date")
   (gnc:timepair-le t2 t1))
 
 (define (gnc:timepair-eq-date t1 t2)
   (gnc:timepair-eq (timespecCanonicalDayTime t1)
 		   (timespecCanonicalDayTime t2)))
 
+(define (gnc:time64-le-date t1 t2)
+  (<= (time64CanonicalDayTime t1)
+      (time64CanonicalDayTime t2)))
+
+(define (gnc:time64-ge-date t1 t2)
+  (gnc:time64-le-date t2 t1))
+
 ;; Build a list of time intervals. 
 ;;
 ;; Note that the last interval will be shorter than <incr> if
 ;; (<curd>-<endd>) is not an integer multiple of <incr>. If you don't
 ;; want that you'll have to write another function.
-(define (gnc:make-date-interval-list curd endd incr) 
+(define (gnc:make-datepair-interval-list curd endd incr)
+  (gnc:warn "deprecated gnc:make-date-interval-list")
   (cond ((gnc:timepair-later curd endd)
 	 (let ((nextd (incdate curd incr)))
 	   (cond ((gnc:timepair-later nextd endd)
@@ -298,18 +370,35 @@
 		  (else (cons (list curd endd '()) '())))))
 	(else '())))
 
+(define (gnc:make-date-interval-list current-date end-date increment)
+  (if (< current-date end-date)
+      (let ((next-date (incdate64 current-date increment)))
+        (if (< next-date end-date)
+            (cons (list current-date (decdate64 next-date SecDelta) '())
+                  (gnc:make-date-interval-list next-date end-date increment))
+            (cons (list current-date end-date '())
+                  '())))
+      '()))
+  
 ;; Build a list of times.  The dates are evenly spaced with the
 ;; stepsize 'incr'. If the difference of 'startdate' and 'enddate' is
 ;; not an integer multiple of 'incr', 'enddate' will be added as the
 ;; last element of the list, thus making the last interval smaller
 ;; than 'incr'.
-(define (gnc:make-date-list startdate enddate incr) 
+(define (gnc:make-datepair-list startdate enddate incr)
+  (gnc:warn "deprecated gnc:make-date-list")
   (cond ((gnc:timepair-later startdate enddate)
 	 (cons startdate 
 	       (gnc:make-date-list (incdate startdate incr) 
 				   enddate incr)))
 	(else (list enddate))))
 
+(define (gnc:make-date-list startdate enddate incr)
+  (if (< startdate enddate)
+      (cons startdate
+            (gnc:make-date-list (incdate64 startdate incr)
+                                enddate incr))
+      (list enddate)))
 
 ; A reference zero date - the Beginning Of The Epoch
 ; Note: use of eval is evil... by making this a generator function, 
@@ -401,6 +490,7 @@
 
 ;; Find difference in seconds time 1 and time2
 (define (gnc:timepair-delta t1 t2)
+  (gnc:warn "(gnc:timepair-delta) obsolete. use (-) directly")
   (- (gnc:timepair->secs t2) (gnc:timepair->secs t1)))
 
 ;; find float difference between times 
@@ -419,6 +509,7 @@
 ;; converts it to be midday that day.
 
 (define (gnc:timepair-start-day-time tp)
+  (gnc:warn "(gnc:timepair-start-day-time) obsolete")
   (let ((bdt (gnc:timepair->date tp)))
     (set-tm:sec bdt 0)
     (set-tm:min bdt 0)
@@ -427,6 +518,7 @@
     (gnc:date->timepair bdt)))
 
 (define (gnc:timepair-end-day-time tp)
+  (gnc:warn "(gnc:timepair-end-day-time) obsolete")
   (let ((bdt (gnc:timepair->date tp)))
     (set-tm:sec bdt 59)
     (set-tm:min bdt 59)
@@ -435,11 +527,37 @@
     (gnc:date->timepair bdt)))
 
 (define (gnc:timepair-previous-day tp)
+  (gnc:warn "gnc:timepair-previous-day obsolete")
   (decdate tp DayDelta))
 
 (define (gnc:timepair-next-day tp)
+  (gnc:warn "gnc:timepair-next-day obsolete")
   (incdate tp DayDelta))
 
+;; new time64 helper functions
+(define (gnc:time64-start-day-time t64)
+  (let ((bdt (gnc-localtime t64)))
+    (set-tm:sec bdt 0)
+    (set-tm:min bdt 0)
+    (set-tm:hour bdt 0)
+    (set-tm:isdst bdt -1)
+    (gnc-mktime bdt)))
+
+(define (gnc:time64-end-day-time t64)
+  (let ((bdt (gnc-localtime t64)))
+    (set-tm:sec bdt 59)
+    (set-tm:min bdt 59)
+    (set-tm:hour bdt 23)
+    (set-tm:isdst bdt -1)
+    (gnc-mktime bdt)))
+
+(define (gnc:time64-previous-day t64)
+  (decdate64 t64 DayDelta))
+
+(define (gnc:time64-next-day t64)
+  (incdate64 t64 DayDelta))
+
+
 (define (gnc:reldate-get-symbol x) (vector-ref x 0))
 (define (gnc:reldate-get-string x) (vector-ref x 1))
 (define (gnc:reldate-get-desc x) (vector-ref x 2))
@@ -486,7 +604,7 @@
     (set-tm:mday now 1)
     (set-tm:mon now 0)
     (set-tm:isdst now -1)
-    (gnc:date->timepair now)))
+    (gnc-mktime now)))
 
 (define (gnc:get-end-cal-year)
   (let ((now (gnc-localtime (current-time))))
@@ -496,7 +614,7 @@
     (set-tm:mday now 31)
     (set-tm:mon now 11)
     (set-tm:isdst now -1)
-    (gnc:date->timepair now)))
+    (gnc-mktime now)))
 
 (define (gnc:get-start-prev-year)
   (let ((now (gnc-localtime (current-time))))
@@ -507,7 +625,7 @@
     (set-tm:mon now 0)
     (set-tm:year now (- (tm:year now) 1))
     (set-tm:isdst now -1)
-    (gnc:date->timepair now)))
+    (gnc-mktime now)))
 
 (define (gnc:get-end-prev-year)
   (let ((now (gnc-localtime (current-time))))
@@ -518,7 +636,7 @@
     (set-tm:mon now 11)
     (set-tm:year now (- (tm:year now) 1))
     (set-tm:isdst now -1)
-    (gnc:date->timepair now)))
+    (gnc-mktime now)))
 
 (define (gnc:get-start-next-year)
   (let ((now (gnc-localtime (current-time))))
@@ -529,7 +647,7 @@
     (set-tm:mon now 0)
     (set-tm:year now (+ (tm:year now) 1))
     (set-tm:isdst now -1)
-    (gnc:date->timepair now)))
+    (gnc-mktime now)))
 
 (define (gnc:get-end-next-year)
   (let ((now (gnc-localtime (current-time))))
@@ -540,13 +658,13 @@
     (set-tm:mon now 11)
     (set-tm:year now (+ (tm:year now) 1))
     (set-tm:isdst now -1)
-    (gnc:date->timepair now)))
+    (gnc-mktime now)))
 
 (define (gnc:get-start-accounting-period)
-  (gnc:secs->timepair (gnc-accounting-period-fiscal-start)))
+  (gnc-accounting-period-fiscal-start))
 
 (define (gnc:get-end-accounting-period)
-  (gnc:secs->timepair (gnc-accounting-period-fiscal-end)))
+  (gnc-accounting-period-fiscal-end))
 
 (define (gnc:get-start-this-month)
   (let ((now (gnc-localtime (current-time))))
@@ -555,7 +673,7 @@
     (set-tm:hour now 0)
     (set-tm:mday now 1)
     (set-tm:isdst now -1)
-    (gnc:date->timepair now)))
+    (gnc-mktime now)))
 
 (define (gnc:get-end-this-month)
   (let ((now (gnc-localtime (current-time))))
@@ -565,7 +683,7 @@
     (set-tm:mday now (gnc:days-in-month (+ (tm:mon now) 1) 
 					(+ (tm:year now) 1900)))
     (set-tm:isdst now -1)
-    (gnc:date->timepair now)))
+    (gnc-mktime now)))
     
 (define (gnc:get-start-prev-month)
   (let ((now (gnc-localtime (current-time))))
@@ -579,7 +697,7 @@
 	  (set-tm:year now (- (tm:year now) 1)))
 	(set-tm:mon now (- (tm:mon now) 1)))
     (set-tm:isdst now -1)
-    (gnc:date->timepair now)))
+    (gnc-mktime now)))
 
 (define (gnc:get-end-prev-month)
   (let ((now (gnc-localtime (current-time))))
@@ -594,7 +712,7 @@
     (set-tm:mday now (gnc:days-in-month (+ (tm:mon now) 1) 
 					(+ (tm:year now) 1900)))
     (set-tm:isdst now -1)
-    (gnc:date->timepair now)))
+    (gnc-mktime now)))
     
 (define (gnc:get-start-next-month)
   (let ((now (gnc-localtime (current-time))))
@@ -608,7 +726,7 @@
 	  (set-tm:year now (+ (tm:year now) 1)))
 	(set-tm:mon now (+ (tm:mon now) 1)))
     (set-tm:isdst now -1)
-    (gnc:date->timepair now)))
+    (gnc-mktime now)))
 
 (define (gnc:get-end-next-month)
   (let ((now (gnc-localtime (current-time))))
@@ -623,7 +741,7 @@
     (set-tm:mday now (gnc:days-in-month (+ (tm:mon now) 1) 
 					(+ (tm:year now) 1900)))
     (set-tm:isdst now -1)
-    (gnc:date->timepair now)))
+    (gnc-mktime now)))
     
 (define (gnc:get-start-current-quarter)
   (let ((now (gnc-localtime (current-time))))
@@ -633,7 +751,7 @@
     (set-tm:mday now 1)
     (set-tm:mon now (- (tm:mon now) (modulo (tm:mon now) 3)))
     (set-tm:isdst now -1)
-    (gnc:date->timepair now)))
+    (gnc-mktime now)))
 
 (define (gnc:get-end-current-quarter)
   (let ((now (gnc-localtime (current-time))))
@@ -645,7 +763,7 @@
     (set-tm:mday now (gnc:days-in-month (+ (tm:mon now) 1)
                                         (+ (tm:year now) 1900)))
     (set-tm:isdst now -1)
-    (gnc:date->timepair now)))
+    (gnc-mktime now)))
 
 (define (gnc:get-start-prev-quarter)
   (let ((now (gnc-localtime (current-time))))
@@ -660,7 +778,7 @@
 	  (set-tm:year now (- (tm:year now) 1)))
 	(set-tm:mon now (- (tm:mon now) 3)))
     (set-tm:isdst now -1)
-    (gnc:date->timepair now)))
+    (gnc-mktime now)))
 
 (define (gnc:get-end-prev-quarter)
   (let ((now (gnc-localtime (current-time))))
@@ -676,7 +794,7 @@
     (set-tm:mday now (gnc:days-in-month (+ (tm:mon now) 1)
                                         (+ (tm:year now) 1900)))
     (set-tm:isdst now -1)
-    (gnc:date->timepair now)))
+    (gnc-mktime now)))
 
 (define (gnc:get-start-next-quarter)
   (let ((now (gnc-localtime (current-time))))
@@ -690,7 +808,7 @@
 	  (set-tm:year now (+ (tm:year now) 1)))
         (set-tm:mon now (+ (tm:mon now) (- 3 (modulo (tm:mon now) 3)))))
     (set-tm:isdst now -1)
-    (gnc:date->timepair now)))
+    (gnc-mktime now)))
 
 (define (gnc:get-end-next-quarter)
   (let ((now (gnc-localtime (current-time))))
@@ -706,10 +824,10 @@
     (set-tm:mday now (gnc:days-in-month (+ (tm:mon now) 1)
                                         (+ (tm:year now) 1900)))
     (set-tm:isdst now -1)
-    (gnc:date->timepair now)))
+    (gnc-mktime now)))
 
 (define (gnc:get-today)
-  (cons (current-time) 0))
+  (current-time))
 
 (define (gnc:get-one-month-ago)
   (let ((now (gnc-localtime (current-time))))
@@ -723,7 +841,7 @@
       (if (> month-length (tm:mday now))
 	  (set-tm:mday now month-length))
       (set-tm:isdst now -1)
-      (gnc:date->timepair now))))
+      (gnc-mktime now))))
 
 (define (gnc:get-three-months-ago)
   (let ((now (gnc-localtime (current-time))))
@@ -737,7 +855,7 @@
       (if (> month-days (tm:mday now))
 	  (set-tm:mday now month-days))
       (set-tm:isdst now -1)
-      (gnc:date->timepair now))))
+      (gnc-mktime now))))
 
 (define (gnc:get-six-months-ago)
   (let ((now (gnc-localtime (current-time))))
@@ -761,7 +879,7 @@
       (if (> month-days (tm:mday now))
 	  (set-tm:mday now month-days))
       (set-tm:isdst now -1)
-      (gnc:date->timepair now))))
+      (gnc-mktime now))))
 
 (define (gnc:get-one-month-ahead)
   (let ((now (gnc-localtime (current-time))))
@@ -775,7 +893,7 @@
       (if (> month-length (tm:mday now))
 	  (set-tm:mday now month-length))
       (set-tm:isdst now -1)
-      (gnc:date->timepair now))))
+      (gnc-mktime now))))
 
 (define (gnc:get-three-months-ahead)
   (let ((now (gnc-localtime (current-time))))
@@ -789,7 +907,7 @@
       (if (> month-days (tm:mday now))
 	  (set-tm:mday now month-days))
       (set-tm:isdst now -1)
-      (gnc:date->timepair now))))
+      (gnc-mktime now))))
 
 (define (gnc:get-six-months-ahead)
   (let ((now (gnc-localtime (current-time))))
@@ -803,7 +921,7 @@
       (if (> month-days (tm:mday now))
 	  (set-tm:mday now month-days))
       (set-tm:isdst now -1)
-      (gnc:date->timepair now))))
+      (gnc-mktime now))))
 
 (define (gnc:get-one-year-ahead)
   (let ((now (gnc-localtime (current-time))))
@@ -813,7 +931,7 @@
       (if (> month-days (tm:mday now))
 	  (set-tm:mday now month-days))
       (set-tm:isdst now -1)
-      (gnc:date->timepair now))))
+      (gnc-mktime now))))
 
 ;; There is no GNC:RELATIVE-DATES list like the one mentioned in
 ;; gnucash-design.info, is there? Here are the currently defined

commit e6ee060121b7b5565faedfe145aac00d6400a96c
Author: lmat <dartme18 at gmail.com>
Date:   Sun Dec 31 21:11:29 2017 -0500

    Adding bill term time64 function

diff --git a/gnucash/gnome/dialog-date-close.c b/gnucash/gnome/dialog-date-close.c
index 0701b9a..5c22725 100644
--- a/gnucash/gnome/dialog-date-close.c
+++ b/gnucash/gnome/dialog-date-close.c
@@ -92,7 +92,7 @@ gnc_dialog_date_close_ok_cb (GtkWidget *widget, gpointer user_data)
     if (ddc->date)
     {
         if (ddc->terms)
-            *(ddc->ts) = gncBillTermComputeDueDate (ddc->terms, *(ddc->ts2));
+            ddc->ts->tv_sec = gncBillTermComputeDueDate (ddc->terms, ddc->ts2->tv_sec);
         else
             *(ddc->ts) = gnc_date_edit_get_date_ts (GNC_DATE_EDIT (ddc->date));
     }
@@ -185,10 +185,10 @@ post_date_changed_cb (GNCDateEdit *gde, gpointer d)
 {
     DialogDateClose *ddc = d;
     Timespec post_date;
-    Timespec due_date;
+    Timespec due_date = {0,0};
 
     post_date = gnc_date_edit_get_date_ts (gde);
-    due_date = gncBillTermComputeDueDate (ddc->terms, post_date);
+    due_date.tv_sec = gncBillTermComputeDueDate (ddc->terms, post_date.tv_sec);
     gnc_date_edit_set_time_ts (GNC_DATE_EDIT (ddc->date), due_date);
 }
 
diff --git a/libgnucash/engine/gncBillTerm.c b/libgnucash/engine/gncBillTerm.c
index 3b6eeb0..525d8f1 100644
--- a/libgnucash/engine/gncBillTerm.c
+++ b/libgnucash/engine/gncBillTerm.c
@@ -820,14 +820,14 @@ compute_time (const GncBillTerm *term, Timespec post_date, int days)
     return res;
 }
 
-Timespec
-gncBillTermComputeDueDate (const GncBillTerm *term, Timespec post_date)
+time64
+gncBillTermComputeDueDate (const GncBillTerm *term, time64 post_date)
 {
-    Timespec res = post_date;
-    if (!term) return res;
-
-    return compute_time (term, post_date, term->due_days);
+    Timespec pass = {post_date, 0};
+    if (!term) return post_date;
+    return compute_time (term, pass, term->due_days).tv_sec;
 }
+
 /* Package-Private functions */
 
 static void _gncBillTermCreate (QofBook *book)
diff --git a/libgnucash/engine/gncBillTerm.h b/libgnucash/engine/gncBillTerm.h
index 88a62ff..d2ccded 100644
--- a/libgnucash/engine/gncBillTerm.h
+++ b/libgnucash/engine/gncBillTerm.h
@@ -164,7 +164,7 @@ gboolean gncBillTermIsFamily (const GncBillTerm *a, const GncBillTerm *b);
 /* functions to compute dates from Bill Terms           */
 
 /* Compute the due date and discount dates from the post date */
-Timespec gncBillTermComputeDueDate (const GncBillTerm *term, Timespec post_date);
+time64 gncBillTermComputeDueDate (const GncBillTerm *term, time64 post_date);
 
 /* deprecated */
 #define gncBillTermGetGUID(x) qof_instance_get_guid (QOF_INSTANCE(x))

commit 6dc982c2c64a0334536c59d7c3a8857bbec32470
Author: lmat <dartme18 at gmail.com>
Date:   Sun Dec 31 09:38:45 2017 -0500

    Some time64 corrections
    
    The build system isn't always catching changed files, so these showed up
    later.

diff --git a/gnucash/import-export/bi-import/dialog-bi-import.c b/gnucash/import-export/bi-import/dialog-bi-import.c
index 4fb5e74..07e6cab 100644
--- a/gnucash/import-export/bi-import/dialog-bi-import.c
+++ b/gnucash/import-export/bi-import/dialog-bi-import.c
@@ -524,7 +524,7 @@ gnc_bi_import_create_bis (GtkListStore * store, QofBook * book,
     Account *acc = NULL;
     enum update {YES = GTK_RESPONSE_YES, NO = GTK_RESPONSE_NO} update;
     GtkWidget *dialog;
-    Timespec today;
+    time64 today;
     InvoiceWindow *iw;
     gchar *new_id = NULL;
     gint64 denom = 0;
@@ -612,14 +612,12 @@ gnc_bi_import_create_bis (GtkListStore * store, QofBook * book,
                 // FIXME: Must check for the return value of qof_scan_date!
                 qof_scan_date (date_opened, &day, &month, &year);
                 gncInvoiceSetDateOpened (invoice,
-                                         gnc_dmy2timespec (day, month, year));
+                                         gnc_dmy2time64 (day, month, year));
             }
             else			// If no date in CSV
             {
                 time64 now = gnc_time (NULL);
-                Timespec now_timespec;
-                timespecFromTime64 (&now_timespec, now);
-                gncInvoiceSetDateOpened (invoice, now_timespec);
+                gncInvoiceSetDateOpened (invoice, now);
             }
             gncInvoiceSetBillingID (invoice, billing_id ? billing_id : "");
             notes = un_escape(notes);
@@ -697,17 +695,17 @@ gnc_bi_import_create_bis (GtkListStore * store, QofBook * book,
             gncEntrySetDateGDate (entry, date);
             g_date_free (date);
         }
-        timespecFromTime64 (&today, gnc_time (NULL));	// set today to the current date
+        today = gnc_time (NULL);	// set today to the current date
         if (strlen (date) != 0)	// If a date is specified in CSV
         {
             GDate *date = g_date_new_dmy(day, month, year);
             gncEntrySetDateGDate(entry, date);
-            gncEntrySetDateEntered(entry, gnc_dmy2timespec (day, month, year));
+            gncEntrySetDateEntered(entry, gnc_dmy2time64 (day, month, year));
         }
         else
         {
             GDate *date = gnc_g_date_new_today();
-            gncEntrySetDateGDate(entry, date); // TODO: DEPRECATED - use gncEntrySetDateGDate() instead!
+            gncEntrySetDateGDate(entry, date);
             gncEntrySetDateEntered(entry, today);
         }
         // Remove escaped quotes
@@ -772,7 +770,7 @@ gnc_bi_import_create_bis (GtkListStore * store, QofBook * book,
                 // autopost this invoice
                 GHashTable *foreign_currs;
                 gboolean auto_pay;
-                Timespec p_date, d_date;
+                time64 p_date, d_date;
                 guint curr_count;
                 gboolean scan_date_r;
                 scan_date_r = qof_scan_date (date_posted, &day, &month, &year);
@@ -789,11 +787,11 @@ gnc_bi_import_create_bis (GtkListStore * store, QofBook * book,
                 // Only auto-post if there's a single currency involved
                 if(curr_count == 0)
                 {
-                    p_date = gnc_dmy2timespec (day, month, year);
+                    p_date = gnc_dmy2time64 (day, month, year);
                     // Check for the return value of qof_scan_date
                     if(qof_scan_date (due_date, &day, &month, &year)) // obtains the due date, or leaves it at date_posted
                     {	
-                        d_date = gnc_dmy2timespec (day, month, year);
+                        d_date = gnc_dmy2time64 (day, month, year);
                     }
                     else
                         d_date = p_date;
@@ -804,7 +802,7 @@ gnc_bi_import_create_bis (GtkListStore * store, QofBook * book,
                         // Check if the currencies match
                         if(gncInvoiceGetCurrency(invoice) == gnc_account_get_currency_or_parent(acc))
                         {
-                            gncInvoicePostToAccount (invoice, acc, &p_date, &d_date,
+                            gncInvoicePostToAccount (invoice, acc, p_date, d_date,
                                                  memo_posted,
                                                  text2bool (accumulatesplits),
                                                  auto_pay);
diff --git a/gnucash/import-export/log-replay/gnc-log-replay.c b/gnucash/import-export/log-replay/gnc-log-replay.c
index a559a16..d79fa22 100644
--- a/gnucash/import-export/log-replay/gnc-log-replay.c
+++ b/gnucash/import-export/log-replay/gnc-log-replay.c
@@ -181,17 +181,20 @@ static split_record interpret_split_record( char *record_line)
     }
     if (strlen(tok_ptr = my_strtok(NULL, "\t")) != 0)
     {
-        record.log_date = gnc_iso8601_to_timespec_gmt(tok_ptr);
+        time64 secs = gnc_iso8601_to_time64_gmt(tok_ptr);
+        record.log_date.tv_sec = secs;
         record.log_date_present = TRUE;
     }
     if (strlen(tok_ptr = my_strtok(NULL, "\t")) != 0)
     {
-        record.date_entered = gnc_iso8601_to_timespec_gmt(tok_ptr);
+        time64 secs = gnc_iso8601_to_time64_gmt(tok_ptr);
+        record.date_entered.tv_sec = secs;
         record.date_entered_present = TRUE;
     }
     if (strlen(tok_ptr = my_strtok(NULL, "\t")) != 0)
     {
-        record.date_posted = gnc_iso8601_to_timespec_gmt(tok_ptr);
+        time64 secs = gnc_iso8601_to_time64_gmt(tok_ptr);
+        record.date_posted.tv_sec = secs;
         record.date_posted_present = TRUE;
     }
     if (strlen(tok_ptr = my_strtok(NULL, "\t")) != 0)
@@ -246,7 +249,8 @@ static split_record interpret_split_record( char *record_line)
     }
     if (strlen(tok_ptr = my_strtok(NULL, "\t")) != 0)
     {
-        record.date_reconciled = gnc_iso8601_to_timespec_gmt(tok_ptr);
+        time64 secs = gnc_iso8601_to_time64_gmt(tok_ptr);
+        record.date_reconciled.tv_sec = secs;
         record.date_reconciled_present = TRUE;
     }
 
@@ -446,11 +450,11 @@ static void  process_trans_record(  FILE *log_file)
                         /*Fill the transaction info*/
                         if (record.date_entered_present)
                         {
-                            xaccTransSetDateEnteredTS(trans, &(record.date_entered));
+                            xaccTransSetDateEnteredSecs(trans, record.date_entered.tv_sec);
                         }
                         if (record.date_posted_present)
                         {
-                            xaccTransSetDatePostedTS(trans, &(record.date_posted));
+                            xaccTransSetDatePostedSecs(trans, record.date_posted.tv_sec);
                         }
                         if (record.trans_num_present)
                         {
diff --git a/gnucash/import-export/qif-imp/assistant-qif-import.c b/gnucash/import-export/qif-imp/assistant-qif-import.c
index 18c9fae..51e27d4 100644
--- a/gnucash/import-export/qif-imp/assistant-qif-import.c
+++ b/gnucash/import-export/qif-imp/assistant-qif-import.c
@@ -1131,6 +1131,7 @@ refresh_old_transactions(QIFImportWindow * wind, int selection)
 
         while (!scm_is_null(possible_matches))
         {
+            Timespec ts_send = {0,0};
             current_xtn = SCM_CAR(possible_matches);
 #define FUNC_NAME "xaccTransCountSplits"
             gnc_xtn     = SWIG_MustGetPtr(SCM_CAR(current_xtn),
@@ -1152,10 +1153,11 @@ refresh_old_transactions(QIFImportWindow * wind, int selection)
             }
 
             gtk_list_store_append(store, &iter);
+            ts_send.tv_sec = xaccTransRetDatePosted(gnc_xtn);
             gtk_list_store_set
             (store, &iter,
              QIF_TRANS_COL_INDEX, rownum++,
-             QIF_TRANS_COL_DATE, gnc_print_date(xaccTransRetDatePostedTS(gnc_xtn)),
+             QIF_TRANS_COL_DATE, gnc_print_date(ts_send),
              QIF_TRANS_COL_DESCRIPTION, xaccTransGetDescription(gnc_xtn),
              QIF_TRANS_COL_AMOUNT, amount_str,
              QIF_TRANS_COL_CHECKED, selected != SCM_BOOL_F,
@@ -3122,6 +3124,7 @@ gnc_ui_qif_import_duplicates_match_prepare (GtkAssistant *assistant,
         duplicates = wind->match_transactions;
         while (!scm_is_null(duplicates))
         {
+            Timespec send_ts = {0,0};
             current_xtn = SCM_CAAR(duplicates);
 #define FUNC_NAME "xaccTransCountSplits"
             gnc_xtn = SWIG_MustGetPtr(current_xtn,
@@ -3138,11 +3141,12 @@ gnc_ui_qif_import_duplicates_match_prepare (GtkAssistant *assistant,
                                     (xaccSplitGetAccount(gnc_split), TRUE));
             }
             gtk_list_store_append(store, &iter);
+            send_ts.tv_sec = xaccTransRetDatePosted(gnc_xtn);
             gtk_list_store_set
             (store, &iter,
              QIF_TRANS_COL_INDEX, rownum++,
              QIF_TRANS_COL_DATE,
-             gnc_print_date(xaccTransRetDatePostedTS(gnc_xtn)),
+             gnc_print_date(send_ts),
              QIF_TRANS_COL_DESCRIPTION, xaccTransGetDescription(gnc_xtn),
              QIF_TRANS_COL_AMOUNT, amount_str,
              -1);
diff --git a/libgnucash/engine/gnc-date.h b/libgnucash/engine/gnc-date.h
index c54df2b..f940817 100644
--- a/libgnucash/engine/gnc-date.h
+++ b/libgnucash/engine/gnc-date.h
@@ -379,8 +379,8 @@ Timespec gnc_dmy2timespec_end (gint day, gint month, gint year);
  */
 Timespec gnc_dmy2timespec_neutral (gint day, gint month, gint year);
 
-/** The gnc_iso8601_to_timespec_gmt() routine converts an ISO-8601 style
- *    date/time string to Timespec.  Please note that ISO-8601 strings
+/** The gnc_iso8601_to_time64_gmt() routine converts an ISO-8601 style
+ *    date/time string to time64.  Please note that ISO-8601 strings
  *    are a representation of Universal Time (UTC), and as such, they
  *    'store' UTC.  To make them human readable, they show time zone
  *    information along with a local-time string.  But fundamentally,

commit 1f050fd1e585946f346343a327d3ae9cc51e311a
Author: lmat <dartme18 at gmail.com>
Date:   Sun Dec 31 07:37:02 2017 -0500

    Transaction members Timespec->time64

diff --git a/gnucash/gnome-utils/dialog-transfer.c b/gnucash/gnome-utils/dialog-transfer.c
index 6ab6fb2..348b4d8 100644
--- a/gnucash/gnome-utils/dialog-transfer.c
+++ b/gnucash/gnome-utils/dialog-transfer.c
@@ -1504,7 +1504,7 @@ create_transaction(XferDialog *xferData, Timespec *ts,
     xaccTransBeginEdit(trans);
 
     xaccTransSetCurrency(trans, xferData->from_commodity);
-    xaccTransSetDatePostedTS(trans, ts);
+    xaccTransSetDatePostedSecs(trans, ts->tv_sec);
 
     /* Trans-Num or Split-Action set with gnc_set_num_action below per book
      * option */
diff --git a/gnucash/gnome-utils/gnc-tree-control-split-reg.c b/gnucash/gnome-utils/gnc-tree-control-split-reg.c
index 16abbd3..1eecf27 100644
--- a/gnucash/gnome-utils/gnc-tree-control-split-reg.c
+++ b/gnucash/gnome-utils/gnc-tree-control-split-reg.c
@@ -1521,7 +1521,7 @@ static gboolean gtcsr_move_current_entry_updown(GncTreeViewSplitReg *view,
         /* Only continue if both have the same date and num, because the
          * "standard ordering" is tied to the date anyway. */
         {
-            Timespec t1, t2;
+            time64 time1, time2;
             GDate d1 = xaccTransGetDatePostedGDate(current_trans),
                   d2 = xaccTransGetDatePostedGDate(target_trans);
             if (g_date_compare(&d1, &d2) != 0)
@@ -1540,9 +1540,9 @@ static gboolean gtcsr_move_current_entry_updown(GncTreeViewSplitReg *view,
             dates as timespec. See the comment in gncEntrySetDateGDate() for the
             reason: Some code used the timespec at noon for the EntryDate, other
             code used the timespec at the start of day. */
-            t1 = xaccTransRetDatePostedTS(current_trans);
-            t2 = xaccTransRetDatePostedTS(target_trans);
-            if (really_do_it && !timespec_equal(&t1, &t2))
+            time1 = xaccTransRetDatePosted(current_trans);
+            time2 = xaccTransRetDatePosted(target_trans);
+            if (really_do_it && time1 != time2)
             {
                 /* Timespecs are not equal, even though the GDates were equal? Then
                 we set the GDates again. This will force the timespecs to be equal
@@ -1587,12 +1587,12 @@ static gboolean gtcsr_move_current_entry_updown(GncTreeViewSplitReg *view,
             /* Swap the date-entered of both entries. That's already
              * sufficient! */
             {
-                Timespec time_current = xaccTransRetDateEnteredTS(current_trans);
-                Timespec time_target = xaccTransRetDateEnteredTS(target_trans);
+                time64 time_current = xaccTransRetDateEntered(current_trans);
+                time64 time_target = xaccTransRetDateEntered(target_trans);
 
                 /* Special treatment for identical times (potentially caused
                  * by the "duplicate entry" command) */
-                if (timespec_equal(&time_current, &time_target))
+                if (time_current == time_target)
                 {
                     g_warning("Surprise - both DateEntered are equal.");
                     /* We just increment the DateEntered of the previously
@@ -1600,14 +1600,14 @@ static gboolean gtcsr_move_current_entry_updown(GncTreeViewSplitReg *view,
                      * issues if multiple entries had this problem, but
                      * whatever. */
                     if (move_up)
-                        time_current.tv_sec++;
+                        ++time_current;
                     else
-                        time_target.tv_sec++;
+                        ++time_target;
                 }
 
                 /* Write the new DateEntered. */
-                xaccTransSetDateEnteredTS(current_trans, &time_target);
-                xaccTransSetDateEnteredTS(target_trans, &time_current);
+                xaccTransSetDateEnteredSecs(current_trans, time_target);
+                xaccTransSetDateEnteredSecs(target_trans, time_current);
 
                 /* FIXME: Do we need to notify anyone about the changed ordering? */
             }
diff --git a/gnucash/gnome-utils/gnc-tree-model-split-reg.c b/gnucash/gnome-utils/gnc-tree-model-split-reg.c
index 6bfed47..7965bf3 100644
--- a/gnucash/gnome-utils/gnc-tree-model-split-reg.c
+++ b/gnucash/gnome-utils/gnc-tree-model-split-reg.c
@@ -832,7 +832,6 @@ gnc_tree_model_split_reg_get_tooltip (GncTreeModelSplitReg *model, gint position
     Transaction *trans;
     const gchar *date_text;
     const gchar *desc_text;
-    Timespec ts = {0,0};
     GList *node;
 
     priv = model->priv;
@@ -849,7 +848,7 @@ gnc_tree_model_split_reg_get_tooltip (GncTreeModelSplitReg *model, gint position
            return g_strconcat ("Blank Transaction", NULL);
         else
         {
-            xaccTransGetDatePostedTS (trans, &ts);
+            Timespec ts = {xaccTransRetDatePosted (trans), 0};
             date_text = gnc_print_date (ts);
             desc_text = xaccTransGetDescription (trans);
             model->current_trans = trans;
diff --git a/gnucash/gnome-utils/gnc-tree-util-split-reg.c b/gnucash/gnome-utils/gnc-tree-util-split-reg.c
index 62360bc..e7f81fd 100644
--- a/gnucash/gnome-utils/gnc-tree-util-split-reg.c
+++ b/gnucash/gnome-utils/gnc-tree-util-split-reg.c
@@ -192,7 +192,7 @@ gtu_sr_handle_exchange_rate (GncTreeViewSplitReg *view, gnc_numeric amount, Tran
 
         /* Get per book option */
         gnc_xfer_dialog_set_num (xfer, gnc_get_num_action (trans, split));
-        gnc_xfer_dialog_set_date (xfer, timespecToTime64 (xaccTransRetDatePostedTS (trans)));
+        gnc_xfer_dialog_set_date (xfer, xaccTransRetDatePosted (trans));
 
         value = amount;
         if (gnc_xfer_dialog_run_exchange_dialog (xfer, &rate_split, value, reg_acc, trans, xfer_comm, expanded))
diff --git a/gnucash/gnome-utils/gnc-tree-view-split-reg.c b/gnucash/gnome-utils/gnc-tree-view-split-reg.c
index 9a9b760..0506270 100644
--- a/gnucash/gnome-utils/gnc-tree-view-split-reg.c
+++ b/gnucash/gnome-utils/gnc-tree-view-split-reg.c
@@ -1474,33 +1474,23 @@ gtv_sr_cdf0 (GtkTreeViewColumn *col, GtkCellRenderer *cell, GtkTreeModel *s_mode
             show_extra_dates = TRUE;
 
         if (is_trow1) {
-            Timespec ts = {0,0};
-            xaccTransGetDatePostedTS (trans, &ts);
+            Timespec ts = {xaccTransRetDatePosted (trans),0};
             //If the time returned by xaccTransGetDatePostedTS is 0 then assume it
             //is a new transaction and set the time to current time to show current
             //date on new transactions
             if (ts.tv_sec == 0)
-            {
                 ts.tv_sec = gnc_time (NULL);
-                //xaccTransSetDatePostedSecs (trans, ts.tv_sec);
-            }//if
             s = gnc_print_date (ts);
             editable = TRUE;
         }
         else if (is_trow2 && show_extra_dates) {
-            Timespec ts = {0,0};
-
+            Timespec ts = {xaccTransRetDateEntered (trans),0};
             g_object_set (cell, "cell-background", YELLOWCELL, (gchar*)NULL);
-
-            xaccTransGetDateEnteredTS (trans, &ts);
             //If the time returned by xaccTransGetDateEnteredTS is 0 then assume it
             //is a new transaction and set the time to current time to show current
             //date on new transactions
             if (ts.tv_sec == 0)
-            {
                 ts.tv_sec = gnc_time (NULL);
-                //xaccTransSetDateEnteredSecs (trans, ts.tv_sec);
-            }//if
             s = gnc_print_date (ts);
             editable = FALSE;
         }
@@ -1559,12 +1549,10 @@ gtv_sr_cdf0 (GtkTreeViewColumn *col, GtkCellRenderer *cell, GtkTreeModel *s_mode
             g_object_set (cell, "cell-background", "white", (gchar*)NULL);
 
         if (is_trow1) {
-            Timespec ts = {0,0};
-
             /* Only print the due date for invoice transactions */
             if (type == TXN_TYPE_INVOICE)
             {
-                xaccTransGetDateDueTS (trans, &ts);
+                Timespec ts = {xaccTransRetDateDue (trans), 0};
                 s = gnc_print_date (ts);
                 editable = FALSE;
             }
@@ -2518,21 +2506,18 @@ gtv_sr_begin_edit (GncTreeViewSplitReg *view, Transaction *trans)
 
     if (trans != view->priv->dirty_trans)
     {
-        Timespec ts = {0,0};
-        xaccTransGetDatePostedTS (trans, &ts);
-
+        time64 time = xaccTransRetDatePosted (trans);
         if (!xaccTransIsOpen (trans))
             xaccTransBeginEdit (trans);
         view->priv->dirty_trans = trans;
 
-        if (ts.tv_sec == 0)
+        if (!time)
         {
             //If the time returned by xaccTransGetDatePostedTS is 0 then assume it
             //is a new transaction and set the time to current time to show current
             //date on new transactions
-
-            ts.tv_sec = gnc_time (NULL);
-            xaccTransSetDatePostedSecs (trans, ts.tv_sec);
+            time = gnc_time (NULL);
+            xaccTransSetDatePostedSecs (trans, time);
         }
     }
     LEAVE(" ");
diff --git a/gnucash/gnome/dialog-trans-assoc.c b/gnucash/gnome/dialog-trans-assoc.c
index 5f83eeb..e83f119 100644
--- a/gnucash/gnome/dialog-trans-assoc.c
+++ b/gnucash/gnome/dialog-trans-assoc.c
@@ -344,8 +344,7 @@ get_trans_info (AssocDialog *assoc_dialog)
             {
                 gchar *uri_u;
                 gboolean rel = FALSE;
-                Timespec ts = {0,0};
-                xaccTransGetDatePostedTS (trans, &ts);
+                Timespec ts = {xaccTransRetDatePosted (trans),0};
 
                 if (ts.tv_sec == 0)
                     ts.tv_sec = gnc_time (NULL);
diff --git a/gnucash/import-export/csv-imp/gnc-trans-props.cpp b/gnucash/import-export/csv-imp/gnc-trans-props.cpp
index de0d886..2aaae34 100644
--- a/gnucash/import-export/csv-imp/gnc-trans-props.cpp
+++ b/gnucash/import-export/csv-imp/gnc-trans-props.cpp
@@ -552,10 +552,10 @@ static void trans_add_split (Transaction* trans, Account* account, GncNumeric am
         value = amount * *price;
     else
     {
-        auto tts = xaccTransRetDatePostedTS (trans);
+        Timespec ts = {xaccTransRetDatePosted (trans), 0};
         /* Import data didn't specify price, let's lookup the nearest in time */
         auto nprice = gnc_pricedb_lookup_nearest_in_time(gnc_pricedb_get_db(book),
-                acct_comm, trans_curr, tts);
+                acct_comm, trans_curr, ts);
         if (nprice)
         {
             /* Found a usable price. Let's check if the conversion direction is right */
diff --git a/gnucash/register/ledger-core/split-register-model-save.c b/gnucash/register/ledger-core/split-register-model-save.c
index 2f7cb19..e785827 100644
--- a/gnucash/register/ledger-core/split-register-model-save.c
+++ b/gnucash/register/ledger-core/split-register-model-save.c
@@ -98,16 +98,13 @@ gnc_split_register_save_due_date_cell (BasicCell * cell,
     SRSaveData *sd = save_data;
     const char *value;
     time64 time;
-    Timespec ts;
     g_return_if_fail (gnc_basic_cell_has_name (cell, DDUE_CELL));
     value = gnc_basic_cell_get_value (cell);
     /* commit any pending changes */
     gnc_date_cell_commit ((DateCell *) cell);
     DEBUG ("DATE: %s", value ? value : "(null)");
     gnc_date_cell_get_date ((DateCell *) cell, &time);
-    ts.tv_sec = time;
-    ts.tv_nsec = 0;
-    xaccTransSetDateDueTS (sd->trans, &ts);
+    xaccTransSetDateDue (sd->trans, time);
 }
 
 static void
diff --git a/gnucash/register/ledger-core/split-register-model.c b/gnucash/register/ledger-core/split-register-model.c
index f011f13..c74616d 100644
--- a/gnucash/register/ledger-core/split-register-model.c
+++ b/gnucash/register/ledger-core/split-register-model.c
@@ -829,7 +829,7 @@ gnc_split_register_get_due_date_entry (VirtualLocation virt_loc,
     SplitRegister *reg = user_data;
     Transaction *trans;
     Split *split;
-    Timespec ts;
+    Timespec ts = {0, 0};
     gboolean is_current;
     char type;
 
@@ -866,7 +866,7 @@ gnc_split_register_get_due_date_entry (VirtualLocation virt_loc,
         return NULL;
     }
 
-    xaccTransGetDateDueTS (trans, &ts);
+    ts.tv_sec = xaccTransRetDateDue (trans);
     //PWARN ("returning valid due_date entry");
 
     return gnc_print_date (ts);
@@ -881,14 +881,14 @@ gnc_split_register_get_date_entry (VirtualLocation virt_loc,
     SplitRegister *reg = user_data;
     Transaction *trans;
     Split *split;
-    Timespec ts;
+    Timespec ts = {0, 0};
 
     split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
     trans = xaccSplitGetParent (split);
     if (!trans)
         return NULL;
 
-    xaccTransGetDatePostedTS (trans, &ts);
+    ts.tv_sec = xaccTransRetDatePosted (trans);
 
     return gnc_print_date (ts);
 }
diff --git a/libgnucash/backend/xml/gnc-transaction-xml-v2.cpp b/libgnucash/backend/xml/gnc-transaction-xml-v2.cpp
index 06fc186..ba19590 100644
--- a/libgnucash/backend/xml/gnc-transaction-xml-v2.cpp
+++ b/libgnucash/backend/xml/gnc-transaction-xml-v2.cpp
@@ -57,6 +57,13 @@ add_gnc_num (xmlNodePtr node, const gchar* tag, gnc_numeric num)
 }
 
 static void
+add_time64 (xmlNodePtr node, const gchar * tag, time64 time, gboolean always)
+{
+    if (always || time)
+        xmlAddChild (node, time64_to_dom_tree (tag, time));
+}
+
+static void
 add_timespec (xmlNodePtr node, const gchar* tag, Timespec tms, gboolean always)
 {
     if (always || tms.tv_sec)
@@ -172,10 +179,10 @@ gnc_transaction_dom_tree_create (Transaction* trn)
     }
     g_free (str);
 
-    add_timespec (ret, "trn:date-posted", xaccTransRetDatePostedTS (trn), TRUE);
+    add_time64 (ret, "trn:date-posted", xaccTransRetDatePosted (trn), TRUE);
 
-    add_timespec (ret, "trn:date-entered",
-                  xaccTransRetDateEnteredTS (trn), TRUE);
+    add_time64 (ret, "trn:date-entered",
+                  xaccTransRetDateEntered (trn), TRUE);
 
     str = g_strdup (xaccTransGetDescription (trn));
     if (str)
@@ -426,6 +433,16 @@ set_tran_string (xmlNodePtr node, Transaction* trn,
     return TRUE;
 }
 
+static gboolean
+set_tran_time64 (xmlNodePtr node, Transaction * trn,
+        void (*func) (Transaction *, time64))
+{
+    time64 time = dom_tree_to_time64 (node);
+    if (!dom_tree_valid_time64 (time, node->name)) return FALSE;
+    func (trn, time);
+    return TRUE;
+}
+
 static inline gboolean
 set_tran_date (xmlNodePtr node, Transaction* trn,
                void (*func) (Transaction* trn, const Timespec* tm))
@@ -481,7 +498,7 @@ trn_date_posted_handler (xmlNodePtr node, gpointer trans_pdata)
     struct trans_pdata* pdata = static_cast<decltype (pdata)> (trans_pdata);
     Transaction* trn = pdata->trans;
 
-    return set_tran_date (node, trn, xaccTransSetDatePostedTS);
+    return set_tran_time64 (node, trn, xaccTransSetDatePostedSecs);
 }
 
 static gboolean
@@ -490,7 +507,7 @@ trn_date_entered_handler (xmlNodePtr node, gpointer trans_pdata)
     struct trans_pdata* pdata = static_cast<decltype (pdata)> (trans_pdata);
     Transaction* trn = pdata->trans;
 
-    return set_tran_date (node, trn, xaccTransSetDateEnteredTS);
+    return set_tran_time64 (node, trn, xaccTransSetDateEnteredSecs);
 }
 
 static gboolean
diff --git a/libgnucash/backend/xml/test/test-file-stuff.cpp b/libgnucash/backend/xml/test/test-file-stuff.cpp
index d378d52..bde3bd6 100644
--- a/libgnucash/backend/xml/test/test-file-stuff.cpp
+++ b/libgnucash/backend/xml/test/test-file-stuff.cpp
@@ -277,10 +277,9 @@ equals_node_val_vs_kvp_frame (xmlNodePtr node, const KvpFrame* frm)
 }
 
 gboolean
-equals_node_val_vs_date (xmlNodePtr node, const Timespec tm)
+equals_node_val_vs_date (xmlNodePtr node, time64 time)
 {
-    time64 time = dom_tree_to_time64 (node);
-    return time == tm.tv_sec;
+    return time == dom_tree_to_time64 (node);
 }
 
 /***********************************************************************/
diff --git a/libgnucash/backend/xml/test/test-file-stuff.h b/libgnucash/backend/xml/test/test-file-stuff.h
index feea972..fd9e00e 100644
--- a/libgnucash/backend/xml/test/test-file-stuff.h
+++ b/libgnucash/backend/xml/test/test-file-stuff.h
@@ -57,7 +57,7 @@ gboolean equals_node_val_vs_guid (xmlNodePtr node, const GncGUID* id);
 gboolean equals_node_val_vs_commodity (xmlNodePtr node,
                                        const gnc_commodity* com, QofBook*);
 gboolean equals_node_val_vs_kvp_frame (xmlNodePtr node, const KvpFrame* frm);
-gboolean equals_node_val_vs_date (xmlNodePtr node, const Timespec tm);
+gboolean equals_node_val_vs_date (xmlNodePtr node, time64);
 gboolean equals_node_val_vs_int (xmlNodePtr node, gint64 val);
 gboolean equals_node_val_vs_boolean (xmlNodePtr node, gboolean val);
 
diff --git a/libgnucash/backend/xml/test/test-xml-transaction.cpp b/libgnucash/backend/xml/test/test-xml-transaction.cpp
index 1154b3b..4d54ef5 100644
--- a/libgnucash/backend/xml/test/test-xml-transaction.cpp
+++ b/libgnucash/backend/xml/test/test-xml-transaction.cpp
@@ -287,14 +287,14 @@ node_and_transaction_equal (xmlNodePtr node, Transaction* trn)
         }
         else if (g_strcmp0 ((char*)mark->name, "trn:date-posted") == 0)
         {
-            if (!equals_node_val_vs_date (mark, xaccTransRetDatePostedTS (trn)))
+            if (!equals_node_val_vs_date (mark, xaccTransRetDatePosted (trn)))
             {
                 return "posted dates differ";
             }
         }
         else if (g_strcmp0 ((char*)mark->name, "trn:date-entered") == 0)
         {
-            if (!equals_node_val_vs_date (mark, xaccTransRetDateEnteredTS (trn)))
+            if (!equals_node_val_vs_date (mark, xaccTransRetDateEntered (trn)))
             {
                 return "entered dates differ";
             }
diff --git a/libgnucash/engine/Account.cpp b/libgnucash/engine/Account.cpp
index a4d4995..84cd1e0 100644
--- a/libgnucash/engine/Account.cpp
+++ b/libgnucash/engine/Account.cpp
@@ -3292,7 +3292,6 @@ xaccAccountGetBalanceAsOfDate (Account *acc, time64 date)
      */
     AccountPrivate *priv;
     GList   *lp;
-    Timespec ts, trans_ts;
     gboolean found = FALSE;
     gnc_numeric balance;
 
@@ -3316,15 +3315,12 @@ xaccAccountGetBalanceAsOfDate (Account *acc, time64 date)
      * xaccAccountGetPresentBalance gets this right, and its algorithm
      * should be used here.
      */
-    ts.tv_sec = date;
-    ts.tv_nsec = 0;
 
     lp = priv->splits;
     while ( lp && !found )
     {
-        xaccTransGetDatePostedTS( xaccSplitGetParent( (Split *)lp->data ),
-                                  &trans_ts );
-        if ( timespec_cmp( &trans_ts, &ts ) >= 0 )
+        time64 trans_time = xaccTransRetDatePosted( xaccSplitGetParent( (Split *)lp->data ));
+        if ( trans_time >= date )
             found = TRUE;
         else
             lp = lp->next;
diff --git a/libgnucash/engine/Query.c b/libgnucash/engine/Query.c
index 96fb920..7aa4060 100644
--- a/libgnucash/engine/Query.c
+++ b/libgnucash/engine/Query.c
@@ -597,13 +597,13 @@ xaccQueryGetEarliestDateFound(QofQuery * q)
 
     /* Safe until 2038 on archs where time64 is 32bit */
     sp = spl->data;
-    earliest = sp->parent->date_posted.tv_sec;
+    earliest = sp->parent->date_posted;
     for (; spl; spl = spl->next)
     {
         sp = spl->data;
-        if (sp->parent->date_posted.tv_sec < earliest)
+        if (sp->parent->date_posted < earliest)
         {
-            earliest = sp->parent->date_posted.tv_sec;
+            earliest = sp->parent->date_posted;
         }
     }
     return earliest;
@@ -627,9 +627,9 @@ xaccQueryGetLatestDateFound(QofQuery * q)
     for (; spl; spl = spl->next)
     {
         sp = spl->data;
-        if (sp->parent->date_posted.tv_sec > latest)
+        if (sp->parent->date_posted > latest)
         {
-            latest = sp->parent->date_posted.tv_sec;
+            latest = sp->parent->date_posted;
         }
     }
     return latest;
diff --git a/libgnucash/engine/Scrub.c b/libgnucash/engine/Scrub.c
index f168a24..86f0791 100644
--- a/libgnucash/engine/Scrub.c
+++ b/libgnucash/engine/Scrub.c
@@ -1399,11 +1399,11 @@ xaccTransScrubPostedDate (Transaction *trans)
 {
     time64 orig = xaccTransGetDate(trans);
     GDate date = xaccTransGetDatePostedGDate(trans);
-    Timespec ts = gdate_to_timespec(date);
-    if (orig && orig != ts.tv_sec)
+    time64 time = gdate_to_time64(date);
+    if (orig && orig != time)
     {
         /* xaccTransSetDatePostedTS handles committing the change. */
-        xaccTransSetDatePostedTS(trans, &ts);
+        xaccTransSetDatePostedSecs(trans, time);
     }
 }
 
diff --git a/libgnucash/engine/Split.c b/libgnucash/engine/Split.c
index 6e18d15..99da4ee 100644
--- a/libgnucash/engine/Split.c
+++ b/libgnucash/engine/Split.c
@@ -1538,11 +1538,9 @@ xaccSplitOrderDateOnly (const Split *sa, const Split *sb)
     if ( !tb ) return -1;
     if ( !ta ) return +1;
 
-    /* if dates differ, return */
-    DATE_CMP(ta, tb, date_posted);
-
-    /* If the dates are the same, do not change the order */
-    return -1;
+    if (ta->date_posted == tb->date_posted)
+        return -1; // Keep the same order
+    return (ta->date_posted > tb->date_posted) - (ta->date_posted < tb->date_posted);
 }
 
 static gboolean
diff --git a/libgnucash/engine/TransLog.c b/libgnucash/engine/TransLog.c
index bb15fd3..7584bc0 100644
--- a/libgnucash/engine/TransLog.c
+++ b/libgnucash/engine/TransLog.c
@@ -227,7 +227,6 @@ xaccTransWriteLog (Transaction *trans, char flag)
     char split_guid_str[GUID_ENCODING_LENGTH + 1];
     const char *trans_notes;
     char dnow[100], dent[100], dpost[100], drecn[100];
-    Timespec ts;
 
     if (!gen_logs)
     {
@@ -236,21 +235,16 @@ xaccTransWriteLog (Transaction *trans, char flag)
     }
     if (!trans_log) return;
 
-    timespecFromTime64(&ts, gnc_time (NULL));
-    gnc_timespec_to_iso8601_buff (ts, dnow);
-
-    timespecFromTime64(&ts, trans->date_entered.tv_sec);
-    gnc_timespec_to_iso8601_buff (ts, dent);
-
-    timespecFromTime64(&ts, trans->date_posted.tv_sec);
-    gnc_timespec_to_iso8601_buff (ts, dpost);
-
+    gnc_time64_to_iso8601_buff (gnc_time(NULL), dnow);
+    gnc_time64_to_iso8601_buff (trans->date_entered, dent);
+    gnc_time64_to_iso8601_buff (trans->date_posted, dpost);
     guid_to_string_buff (xaccTransGetGUID(trans), trans_guid_str);
     trans_notes = xaccTransGetNotes(trans);
     fprintf (trans_log, "===== START\n");
 
     for (node = trans->splits; node; node = node->next)
     {
+        Timespec ts;
         Split *split = node->data;
         const char * accname = "";
         char acc_guid_str[GUID_ENCODING_LENGTH + 1];
diff --git a/libgnucash/engine/Transaction.c b/libgnucash/engine/Transaction.c
index a541d40..755acae 100644
--- a/libgnucash/engine/Transaction.c
+++ b/libgnucash/engine/Transaction.c
@@ -275,16 +275,10 @@ gnc_transaction_init(Transaction* trans)
     /* Fill in some sane defaults */
     trans->num         = CACHE_INSERT("");
     trans->description = CACHE_INSERT("");
-
     trans->common_currency = NULL;
     trans->splits = NULL;
-
-    trans->date_entered.tv_sec  = 0;
-    trans->date_entered.tv_nsec = 0;
-
-    trans->date_posted.tv_sec  = 0;
-    trans->date_posted.tv_nsec = 0;
-
+    trans->date_entered  = 0;
+    trans->date_posted  = 0;
     trans->marker = 0;
     trans->orig = NULL;
     LEAVE (" ");
@@ -316,6 +310,7 @@ gnc_transaction_get_property(GObject* object,
 {
     Transaction* tx;
     gchar *key;
+    Timespec ts = {0,0};
 
     g_return_if_fail(GNC_IS_TRANSACTION(object));
 
@@ -332,10 +327,12 @@ gnc_transaction_get_property(GObject* object,
         g_value_take_object(value, tx->common_currency);
         break;
     case PROP_POST_DATE:
-        g_value_set_boxed(value, &tx->date_posted);
+        ts.tv_sec = tx->date_posted;
+        g_value_set_boxed(value, &ts);
         break;
     case PROP_ENTER_DATE:
-        g_value_set_boxed(value, &tx->date_entered);
+        ts.tv_sec = tx->date_entered;
+        g_value_set_boxed(value, &ts);
         break;
     case PROP_INVOICE:
         qof_instance_get_kvp (QOF_INSTANCE (tx), value, 2, GNC_INVOICE_ID, GNC_INVOICE_GUID);
@@ -378,10 +375,10 @@ gnc_transaction_set_property(GObject* object,
         xaccTransSetCurrency(tx, g_value_get_object(value));
         break;
     case PROP_POST_DATE:
-        xaccTransSetDatePostedTS(tx, g_value_get_boxed(value));
+        xaccTransSetDatePostedSecs(tx, ((Timespec*)g_value_get_boxed(value))->tv_sec);
         break;
     case PROP_ENTER_DATE:
-        xaccTransSetDateEnteredTS(tx, g_value_get_boxed(value));
+        xaccTransSetDateEnteredSecs(tx, ((Timespec*)g_value_get_boxed(value))->tv_sec);
         break;
     case PROP_INVOICE:
         qof_instance_set_kvp (QOF_INSTANCE (tx), value, 2, GNC_INVOICE_ID, GNC_INVOICE_GUID);
@@ -741,7 +738,6 @@ void
 xaccTransCopyFromClipBoard(const Transaction *from_trans, Transaction *to_trans,
                            const Account *from_acc, Account *to_acc, gboolean no_date)
 {
-    Timespec ts = {0,0};
     gboolean change_accounts = FALSE;
     GList *node;
 
@@ -764,8 +760,7 @@ xaccTransCopyFromClipBoard(const Transaction *from_trans, Transaction *to_trans,
     xaccTransSetNotes(to_trans, xaccTransGetNotes(from_trans));
     if(!no_date)
     {
-        xaccTransGetDatePostedTS(from_trans, &ts);
-        xaccTransSetDatePostedTS(to_trans, &ts);
+        xaccTransSetDatePostedSecs(to_trans, xaccTransRetDatePosted (from_trans));
     }
 
     /* Each new split will be parented to 'to' */
@@ -813,12 +808,8 @@ xaccFreeTransaction (Transaction *trans)
     /* Just in case someone looks up freed memory ... */
     trans->num         = (char *) 1;
     trans->description = NULL;
-
-    trans->date_entered.tv_sec = 0;
-    trans->date_entered.tv_nsec = 0;
-    trans->date_posted.tv_sec = 0;
-    trans->date_posted.tv_nsec = 0;
-
+    trans->date_entered = 0;
+    trans->date_posted = 0;
     if (trans->orig)
     {
         xaccFreeTransaction (trans->orig);
@@ -892,24 +883,24 @@ xaccTransEqual(const Transaction *ta, const Transaction *tb,
         return FALSE;
     }
 
-    if (timespec_cmp(&(ta->date_entered), &(tb->date_entered)))
+    if (ta->date_entered != tb->date_entered)
     {
         char buf1[100];
         char buf2[100];
 
-        (void)gnc_timespec_to_iso8601_buff(ta->date_entered, buf1);
-        (void)gnc_timespec_to_iso8601_buff(tb->date_entered, buf2);
+        (void)gnc_time64_to_iso8601_buff(ta->date_entered, buf1);
+        (void)gnc_time64_to_iso8601_buff(tb->date_entered, buf2);
         PINFO ("date entered differs: '%s' vs '%s'", buf1, buf2);
         return FALSE;
     }
 
-    if (timespec_cmp(&(ta->date_posted), &(tb->date_posted)))
+    if (ta->date_posted != tb->date_posted)
     {
         char buf1[100];
         char buf2[100];
 
-        (void)gnc_timespec_to_iso8601_buff(ta->date_posted, buf1);
-        (void)gnc_timespec_to_iso8601_buff(tb->date_posted, buf2);
+        (void)gnc_time64_to_iso8601_buff(ta->date_posted, buf1);
+        (void)gnc_time64_to_iso8601_buff(tb->date_posted, buf2);
         PINFO ("date posted differs: '%s' vs '%s'", buf1, buf2);
         return FALSE;
     }
@@ -1683,9 +1674,9 @@ xaccTransCommitEdit (Transaction *trans)
     }
 
     /* Record the time of last modification */
-    if (0 == trans->date_entered.tv_sec)
+    if (0 == trans->date_entered)
     {
-	trans->date_entered.tv_sec = gnc_time(NULL);
+        trans->date_entered = gnc_time(NULL);
         qof_instance_set_dirty(QOF_INSTANCE(trans));
     }
 
@@ -1890,8 +1881,8 @@ xaccTransOrder_num_action (const Transaction *ta, const char *actna,
     if ( !ta && tb ) return +1;
     if ( !ta && !tb ) return 0;
 
-    /* if dates differ, return */
-    DATE_CMP(ta, tb, date_posted);
+    if (ta->date_posted != tb->date_posted)
+        return (ta->date_posted > tb->date_posted) - (ta->date_posted < tb->date_posted);
 
     /* otherwise, sort on number string */
     if (actna && actnb) /* split action string, if not NULL */
@@ -1907,8 +1898,8 @@ xaccTransOrder_num_action (const Transaction *ta, const char *actna,
     if (na < nb) return -1;
     if (na > nb) return +1;
 
-    /* if dates differ, return */
-    DATE_CMP(ta, tb, date_entered);
+    if (ta->date_entered != tb->date_entered)
+        return (ta->date_entered > tb->date_entered) - (ta->date_entered < tb->date_entered);
 
     /* otherwise, sort on description string */
     da = ta->description ? ta->description : "";
@@ -1925,7 +1916,7 @@ xaccTransOrder_num_action (const Transaction *ta, const char *actna,
 \********************************************************************/
 
 static inline void
-xaccTransSetDateInternal(Transaction *trans, Timespec *dadate, Timespec val)
+xaccTransSetDateInternal(Transaction *trans, time64 *dadate, time64 val)
 {
     xaccTransBeginEdit(trans);
 
@@ -1962,9 +1953,8 @@ set_gains_date_dirty (Transaction *trans)
 void
 xaccTransSetDatePostedSecs (Transaction *trans, time64 secs)
 {
-    Timespec ts = {secs, 0};
     if (!trans) return;
-    xaccTransSetDateInternal(trans, &trans->date_posted, ts);
+    xaccTransSetDateInternal(trans, &trans->date_posted, secs);
     set_gains_date_dirty (trans);
 }
 
@@ -1990,16 +1980,15 @@ xaccTransSetDatePostedGDate (Transaction *trans, GDate date)
     qof_instance_set_kvp (QOF_INSTANCE(trans), &v, 1, TRANS_DATE_POSTED);
     /* mark dirty and commit handled by SetDateInternal */
     xaccTransSetDateInternal(trans, &trans->date_posted,
-                             gdate_to_timespec(date));
+                             gdate_to_time64(date));
     set_gains_date_dirty (trans);
 }
 
 void
 xaccTransSetDateEnteredSecs (Transaction *trans, time64 secs)
 {
-    Timespec ts = {secs, 0};
     if (!trans) return;
-    xaccTransSetDateInternal(trans, &trans->date_entered, ts);
+    xaccTransSetDateInternal(trans, &trans->date_entered, secs);
 }
 
 static void
@@ -2008,37 +1997,24 @@ qofTransSetDatePosted (Transaction *trans, Timespec ts)
     if (!trans) return;
     if ((ts.tv_nsec == 0) && (ts.tv_sec == 0)) return;
     if (!qof_begin_edit(&trans->inst)) return;
-    xaccTransSetDateInternal(trans, &trans->date_posted, ts);
+    xaccTransSetDateInternal(trans, &trans->date_posted, ts.tv_sec);
     set_gains_date_dirty(trans);
     qof_commit_edit(&trans->inst);
 }
 
-void
-xaccTransSetDatePostedTS (Transaction *trans, const Timespec *ts)
-{
-    if (!trans || !ts) return;
-    xaccTransSetDateInternal(trans, &trans->date_posted, *ts);
-    set_gains_date_dirty (trans);
-}
-
 static void
 qofTransSetDateEntered (Transaction *trans, Timespec ts)
 {
+    /*This is called from the query framework, so we'll leave the timespec
+     * until the query framework is converted, too.*/
     if (!trans) return;
     if ((ts.tv_nsec == 0) && (ts.tv_sec == 0)) return;
     if (!qof_begin_edit(&trans->inst)) return;
-    xaccTransSetDateInternal(trans, &trans->date_entered, ts);
+    xaccTransSetDateInternal(trans, &trans->date_entered, ts.tv_sec);
     qof_commit_edit(&trans->inst);
 }
 
 void
-xaccTransSetDateEnteredTS (Transaction *trans, const Timespec *ts)
-{
-    if (!trans || !ts) return;
-    xaccTransSetDateInternal(trans, &trans->date_entered, *ts);
-}
-
-void
 xaccTransSetDate (Transaction *trans, int day, int mon, int year)
 {
     GDate *date;
@@ -2058,17 +2034,11 @@ xaccTransSetDate (Transaction *trans, int day, int mon, int year)
 void
 xaccTransSetDateDue (Transaction * trans, time64 time)
 {
-    Timespec ts_send = {time, 0};
-    xaccTransSetDateDueTS (trans, &ts_send);
-}
-
-void
-xaccTransSetDateDueTS (Transaction *trans, const Timespec *ts)
-{
     GValue v = G_VALUE_INIT;
-    if (!trans || !ts) return;
+    Timespec send_ts = {time, 0};
+    if (!trans) return;
     g_value_init (&v, GNC_TYPE_TIMESPEC);
-    g_value_set_boxed (&v, ts);
+    g_value_set_boxed (&v, &send_ts);
     xaccTransBeginEdit(trans);
     qof_instance_set_kvp (QOF_INSTANCE (trans), &v, 1, TRANS_DATE_DUE_KVP);
     qof_instance_set_dirty(QOF_INSTANCE(trans));
@@ -2377,42 +2347,21 @@ xaccTransGetIsClosingTxn (const Transaction *trans)
 time64
 xaccTransGetDate (const Transaction *trans)
 {
-    return trans ? trans->date_posted.tv_sec : 0;
+    return trans ? trans->date_posted : 0;
 }
 
 /*################## Added for Reg2 #################*/
 time64
 xaccTransGetDateEntered (const Transaction *trans)
 {
-    return trans ? trans->date_entered.tv_sec : 0;
+    return trans ? trans->date_entered : 0;;
 }
 /*################## Added for Reg2 #################*/
 
-void
-xaccTransGetDatePostedTS (const Transaction *trans, Timespec *ts)
-{
-    if (trans && ts)
-        *ts = trans->date_posted;
-}
-
-void
-xaccTransGetDateEnteredTS (const Transaction *trans, Timespec *ts)
-{
-    if (trans && ts)
-        *ts = trans->date_entered;
-}
-
-Timespec
-xaccTransRetDatePostedTS (const Transaction *trans)
-{
-    Timespec ts = {0, 0};
-    return trans ? trans->date_posted : ts;
-}
-
 time64
 xaccTransRetDatePosted (const Transaction *trans)
 {
-    return trans ? trans->date_posted.tv_sec : 0;
+    return trans ? trans->date_posted : 0;
 }
 
 GDate
@@ -2451,44 +2400,24 @@ xaccTransGetDatePostedGDate (const Transaction *trans)
     return result;
 }
 
-Timespec
-xaccTransRetDateEnteredTS (const Transaction *trans)
-{
-    Timespec ts = {0, 0};
-    return trans ? trans->date_entered : ts;
-}
-
 time64
 xaccTransRetDateEntered (const Transaction *trans)
 {
-    return trans ? trans->date_entered.tv_sec : 0;
+    return trans ? trans->date_entered : 0;
 }
 
-void
-xaccTransGetDateDueTS (const Transaction *trans, Timespec *ts)
+time64
+xaccTransRetDateDue(const Transaction *trans)
 {
+    time64 ret = 0;
     GValue v = G_VALUE_INIT;
-    if (!trans || !ts) return;
-
+    if (!trans) return 0;
     qof_instance_get_kvp (QOF_INSTANCE (trans), &v, 1, TRANS_DATE_DUE_KVP);
     if (G_VALUE_HOLDS_BOXED (&v))
-         *ts = *(Timespec*)g_value_get_boxed (&v);
-    if (ts->tv_sec == 0)
-        xaccTransGetDatePostedTS (trans, ts);
-}
-
-time64
-xaccTransRetDateDue(const Transaction *trans)
-{
-    return xaccTransRetDateDueTS (trans).tv_sec;
-}
-
-Timespec
-xaccTransRetDateDueTS (const Transaction *trans)
-{
-    Timespec ts = {0, 0};
-    if (trans) xaccTransGetDateDueTS (trans, &ts);
-    return ts;
+        ret = ((Timespec*)g_value_get_boxed (&v))->tv_sec;
+    if (!ret)
+        return xaccTransRetDatePosted (trans);
+    return ret;
 }
 
 char
@@ -2596,7 +2525,7 @@ gboolean xaccTransInFutureByPostedDate (const Transaction *trans)
 
     present = gnc_time64_get_today_end ();
 
-    if (trans->date_posted.tv_sec > present)
+    if (trans->date_posted > present)
         result = TRUE;
     else
         result = FALSE;
@@ -2881,8 +2810,6 @@ static void
 xaccTransScrubGainsDate (Transaction *trans)
 {
     SplitList *node;
-    Timespec ts = {0, 0};
-//restart_search:
     for (node = trans->splits; node; node = node->next)
     {
         Split *s = node->data;
@@ -2896,13 +2823,10 @@ xaccTransScrubGainsDate (Transaction *trans)
              (s->gains & GAINS_STATUS_DATE_DIRTY)))
         {
             Transaction *source_trans = s->gains_split->parent;
-            ts = source_trans->date_posted;
             s->gains &= ~GAINS_STATUS_DATE_DIRTY;
             s->gains_split->gains &= ~GAINS_STATUS_DATE_DIRTY;
-
-            xaccTransSetDatePostedTS(trans, &ts);
+            xaccTransSetDatePostedSecs(trans, source_trans->date_posted);
             FOR_EACH_SPLIT(trans, s->gains &= ~GAINS_STATUS_DATE_DIRTY);
-            //goto restart_search;
         }
     }
 }
@@ -3015,6 +2939,39 @@ trans_is_balanced_p (const Transaction *trans)
     return trans ? xaccTransIsBalanced(trans) : FALSE;
 }
 
+static Timespec
+xaccTransRetDateEnteredTS (Transaction * trans)
+{
+    Timespec ret = {xaccTransRetDateEntered (trans), 0};
+    return ret;
+}
+
+static void
+qofTransSetDateEnteredTS (Transaction * trans, Timespec t)
+{
+    xaccTransSetDateEnteredSecs (trans, t.tv_sec);
+}
+
+static Timespec
+xaccTransRetDatePostedTS (Transaction * trans)
+{
+    Timespec ret = {xaccTransRetDatePosted (trans), 0};
+    return ret;
+}
+
+static void
+qofTransSetDatePostedTS (Transaction * trans, Timespec t)
+{
+    xaccTransSetDatePostedSecs (trans, t.tv_sec);
+}
+
+static Timespec
+xaccTransRetDateDueTS (Transaction * trans)
+{
+    Timespec ret = {xaccTransRetDateDue (trans), 0};
+    return ret;
+}
+
 gboolean xaccTransRegister (void)
 {
     static QofParam params[] =
@@ -3033,12 +2990,12 @@ gboolean xaccTransRegister (void)
             {
                 TRANS_DATE_ENTERED, QOF_TYPE_DATE,
                 (QofAccessFunc)xaccTransRetDateEnteredTS,
-                (QofSetterFunc)qofTransSetDateEntered
+                (QofSetterFunc)qofTransSetDateEnteredTS
             },
             {
                 TRANS_DATE_POSTED, QOF_TYPE_DATE,
                 (QofAccessFunc)xaccTransRetDatePostedTS,
-                (QofSetterFunc)qofTransSetDatePosted
+                (QofSetterFunc)qofTransSetDatePostedTS
             },
             {
                 TRANS_DATE_DUE, QOF_TYPE_DATE,
diff --git a/libgnucash/engine/Transaction.h b/libgnucash/engine/Transaction.h
index 2ad3123..15aa660 100644
--- a/libgnucash/engine/Transaction.h
+++ b/libgnucash/engine/Transaction.h
@@ -625,21 +625,11 @@ void          xaccTransSetDatePostedSecs (Transaction *trans, time64 time);
  * The posted date is the date when this transaction was posted at the bank. */
 void          xaccTransSetDatePostedSecsNormalized (Transaction *trans, time64 time);
 
-/**  The xaccTransSetDatePostedTS() method does the same thing as
-     xaccTransSetDatePostedSecs(), but takes a struct timespec64. */
-void          xaccTransSetDatePostedTS (Transaction *trans,
-                                        const Timespec *ts);
-
 /** Modify the date of when the transaction was entered. The entered
  * date is the date when the register entry was made. */
 void          xaccTransSetDateEnteredSecs (Transaction *trans, time64 time);
-/** Modify the date of when the transaction was entered. The entered
- * date is the date when the register entry was made. */
-void          xaccTransSetDateEnteredTS (Transaction *trans,
-        const Timespec *ts);
 
 /** Dates and txn-type for A/R and A/P "invoice" postings */
-void	      xaccTransSetDateDueTS (Transaction *trans, const Timespec *ts);
 void          xaccTransSetDateDue (Transaction * trans, time64 time);
 
 /** Retrieve the posted date of the transaction. The posted date is
@@ -651,12 +641,6 @@ time64        xaccTransGetDate (const Transaction *trans);
     the date when this transaction was posted at the bank. (Although
     having different function names, GetDate and GetDatePosted refer
     to the same single date.)*/
-void          xaccTransGetDatePostedTS (const Transaction *trans, Timespec *ts);
-/** Retrieve the posted date of the transaction. The posted date is
-    the date when this transaction was posted at the bank. (Although
-    having different function names, GetDate and GetDatePosted refer
-    to the same single date.)*/
-Timespec      xaccTransRetDatePostedTS (const Transaction *trans);
 time64        xaccTransRetDatePosted   (const Transaction *trans);
 /** Retrieve the posted date of the transaction. The posted date is
     the date when this transaction was posted at the bank. */
@@ -669,17 +653,10 @@ time64        xaccTransGetDateEntered (const Transaction *trans);
 /*################## Added for Reg2 #################*/
 /** Retrieve the date of when the transaction was entered. The entered
  * date is the date when the register entry was made.*/
-void          xaccTransGetDateEnteredTS (const Transaction *trans, Timespec *ts);
-/** Retrieve the date of when the transaction was entered. The entered
- * date is the date when the register entry was made.*/
-Timespec      xaccTransRetDateEnteredTS (const Transaction *trans);
 time64        xaccTransRetDateEntered (const Transaction *trans);
 
 /** Dates and txn-type for A/R and A/P "invoice" postings */
-Timespec      xaccTransRetDateDueTS (const Transaction *trans);
 time64        xaccTransRetDateDue (const Transaction *trans);
-/** Dates and txn-type for A/R and A/P "invoice" postings */
-void	      xaccTransGetDateDueTS (const Transaction *trans, Timespec *ts);
 /** @} */
 
 
diff --git a/libgnucash/engine/TransactionP.h b/libgnucash/engine/TransactionP.h
index 2864a59..7b5bc93 100644
--- a/libgnucash/engine/TransactionP.h
+++ b/libgnucash/engine/TransactionP.h
@@ -75,8 +75,8 @@ struct transaction_s
 {
     QofInstance inst;     /* glbally unique id */
 
-    Timespec date_entered;     /* date register entry was made              */
-    Timespec date_posted;      /* date transaction was posted at bank       */
+    time64 date_entered;     /* date register entry was made              */
+    time64 date_posted;      /* date transaction was posted at bank       */
 
     /* The num field is a arbitrary user-assigned field.
      * It is intended to store a short id number, typically the check number,
diff --git a/libgnucash/engine/cap-gains.c b/libgnucash/engine/cap-gains.c
index c34a265..9d14d9e 100644
--- a/libgnucash/engine/cap-gains.c
+++ b/libgnucash/engine/cap-gains.c
@@ -133,6 +133,7 @@ finder_helper (GNCLot *lot,  gpointer user_data)
     Transaction *trans;
     gnc_numeric bal;
     gboolean opening_is_positive, bal_is_positive;
+    Timespec posted_ts = {0,0};
 
     if (gnc_lot_is_closed (lot)) return NULL;
 
@@ -157,9 +158,10 @@ finder_helper (GNCLot *lot,  gpointer user_data)
         return NULL;
     }
 
-    if (els->date_pred (els->ts, trans->date_posted))
+    posted_ts.tv_sec = trans->date_posted;
+    if (els->date_pred (els->ts, posted_ts))
     {
-        els->ts = trans->date_posted;
+        els->ts.tv_sec = trans->date_posted;
         els->lot = lot;
     }
 
@@ -762,7 +764,6 @@ xaccSplitComputeCapGains(Split *split, Account *gain_acc)
     {
         Transaction *trans;
         Split *lot_split, *gain_split;
-        Timespec ts;
         gboolean new_gain_split;
         gnc_numeric negvalue = gnc_numeric_neg (value);
 
@@ -869,8 +870,8 @@ xaccSplitComputeCapGains(Split *split, Account *gain_acc)
         if (new_gain_split)
         {
             /* Common to both */
-            ts = xaccTransRetDatePostedTS (split->parent);
-            xaccTransSetDatePostedTS (trans, &ts);
+            time64 time = xaccTransRetDatePosted (split->parent);
+            xaccTransSetDatePostedSecs (trans, time);
             xaccTransSetDateEnteredSecs (trans, gnc_time (NULL));
 
             xaccSplitSetAmount (lot_split, zero);
diff --git a/libgnucash/engine/engine-helpers.c b/libgnucash/engine/engine-helpers.c
index 228075f..bbbc99b 100644
--- a/libgnucash/engine/engine-helpers.c
+++ b/libgnucash/engine/engine-helpers.c
@@ -54,17 +54,15 @@ static QofLogModule log_module = GNC_MOD_ENGINE;
 Timespec
 gnc_transaction_get_date_posted(const Transaction *t)
 {
-    Timespec result;
-    xaccTransGetDatePostedTS(t, &result);
-    return(result);
+    Timespec ret = {xaccTransRetDatePosted(t), 0};
+    return ret;
 }
 
 Timespec
 gnc_transaction_get_date_entered(const Transaction *t)
 {
-    Timespec result;
-    xaccTransGetDateEnteredTS(t, &result);
-    return(result);
+    Timespec result = {xaccTransRetDateEntered(t), 0};
+    return result;
 }
 
 Timespec
@@ -78,7 +76,7 @@ gnc_split_get_date_reconciled(const Split *s)
 void
 gnc_transaction_set_date(Transaction *t, Timespec ts)
 {
-    xaccTransSetDatePostedTS(t, &ts);
+    xaccTransSetDatePostedSecs(t, ts.tv_sec);
 }
 
 /** Gets the transaction Number or split Action based on book option:
diff --git a/libgnucash/engine/gnc-date.cpp b/libgnucash/engine/gnc-date.cpp
index a88604f..f4c0cf7 100644
--- a/libgnucash/engine/gnc-date.cpp
+++ b/libgnucash/engine/gnc-date.cpp
@@ -1224,6 +1224,13 @@ gnc_iso8601_to_time64_gmt(const char *cstr)
 \********************************************************************/
 
 char *
+gnc_time64_to_iso8601_buff (time64 time, char * buff)
+{
+    Timespec ts = {time, 0};
+    return gnc_timespec_to_iso8601_buff (ts, buff);
+}
+
+char *
 gnc_timespec_to_iso8601_buff (Timespec ts, char * buff)
 {
     constexpr size_t max_iso_date_length = 32;
diff --git a/libgnucash/engine/gnc-date.h b/libgnucash/engine/gnc-date.h
index 97f0158..c54df2b 100644
--- a/libgnucash/engine/gnc-date.h
+++ b/libgnucash/engine/gnc-date.h
@@ -414,6 +414,7 @@ time64 gnc_iso8601_to_time64_gmt(const gchar *);
  *    on the machine on which it is executing to create the time string.
  */
 gchar * gnc_timespec_to_iso8601_buff (Timespec ts, gchar * buff);
+gchar * gnc_time64_to_iso8601_buff (time64, char * buff);
 
 /** Set the proleptic Gregorian day, month, and year from a Timespec
  * \param ts: input timespec
diff --git a/libgnucash/engine/gncOwner.c b/libgnucash/engine/gncOwner.c
index 2aad3c2..56b6036 100644
--- a/libgnucash/engine/gncOwner.c
+++ b/libgnucash/engine/gncOwner.c
@@ -712,12 +712,12 @@ gncOwnerLotsSortFunc (GNCLot *lotA, GNCLot *lotB)
     if (ia)
         da = gncInvoiceGetDateDue (ia);
     else
-        da = xaccTransRetDatePostedTS (xaccSplitGetParent (gnc_lot_get_earliest_split (lotA))).tv_sec;
+        da = xaccTransRetDatePosted (xaccSplitGetParent (gnc_lot_get_earliest_split (lotA)));
 
     if (ib)
         db = gncInvoiceGetDateDue (ib);
     else
-        db = xaccTransRetDatePostedTS (xaccSplitGetParent (gnc_lot_get_earliest_split (lotB))).tv_sec;
+        db = xaccTransRetDatePosted (xaccSplitGetParent (gnc_lot_get_earliest_split (lotB)));
 
     return (da > db) - (da < db);
 }
@@ -814,7 +814,7 @@ gncOwnerCreatePaymentLot (const GncOwner *owner, Transaction **preset_txn,
         /* set per book option */
         xaccTransSetCurrency (txn, commodity);
         xaccTransSetDateEnteredSecs (txn, gnc_time (NULL));
-        xaccTransSetDatePostedTS (txn, &date);
+        xaccTransSetDatePostedSecs (txn, date.tv_sec);
 
 
         /* The split for the transfer account */
@@ -1100,7 +1100,7 @@ gncOwnerCreateLotLink (GNCLot *from_lot, GNCLot *to_lot, const GncOwner *owner)
     const gchar *name = gncOwnerGetName (gncOwnerGetEndOwner (owner));
     Transaction *ll_txn = NULL;
     gnc_numeric from_lot_bal, to_lot_bal;
-    Timespec from_ts, to_ts;
+    time64 from_time, to_time;
     time64 time_posted;
     Split *split;
 
@@ -1110,12 +1110,12 @@ gncOwnerCreateLotLink (GNCLot *from_lot, GNCLot *to_lot, const GncOwner *owner)
         return;
 
     /* Determine transaction date based on lot splits */
-    from_ts = xaccTransRetDatePostedTS (xaccSplitGetParent (gnc_lot_get_latest_split (from_lot)));
-    to_ts   = xaccTransRetDatePostedTS (xaccSplitGetParent (gnc_lot_get_latest_split (to_lot)));
-    if (timespecToTime64 (from_ts) >= timespecToTime64 (to_ts))
-        time_posted = timespecToTime64 (from_ts);
+    from_time = xaccTransRetDatePosted (xaccSplitGetParent (gnc_lot_get_latest_split (from_lot)));
+    to_time   = xaccTransRetDatePosted (xaccSplitGetParent (gnc_lot_get_latest_split (to_lot)));
+    if (from_time >= to_time)
+        time_posted = from_time;
     else
-        time_posted = timespecToTime64 (to_ts);
+        time_posted = to_time;
 
     /* Figure out how much we can offset between the lots */
     from_lot_bal = gnc_lot_get_balance (from_lot);
@@ -1137,31 +1137,22 @@ gncOwnerCreateLotLink (GNCLot *from_lot, GNCLot *to_lot, const GncOwner *owner)
     if (!ll_txn)
     {
         /* No pre-existing lot link. Create one. */
-        Timespec ts;
-
-        timespecFromTime64 (&ts, time_posted);
-
         ll_txn = xaccMallocTransaction (gnc_lot_get_book (from_lot));
         xaccTransBeginEdit (ll_txn);
-
         xaccTransSetDescription (ll_txn, name ? name : "(Unknown)");
         xaccTransSetCurrency (ll_txn, xaccAccountGetCommodity(acct));
         xaccTransSetDateEnteredSecs (ll_txn, gnc_time (NULL));
-        xaccTransSetDatePostedTS (ll_txn, &ts);
+        xaccTransSetDatePostedSecs (ll_txn, time_posted);
         xaccTransSetTxnType (ll_txn, TXN_TYPE_LINK);
     }
     else
     {
-        Timespec ts = xaccTransRetDatePostedTS (ll_txn);
+        time64 time = xaccTransRetDatePosted (ll_txn);
         xaccTransBeginEdit (ll_txn);
 
         /* Maybe we need to update the post date of the transaction ? */
-        if (time_posted > timespecToTime64 (ts))
-        {
-            timespecFromTime64 (&ts, time_posted);
-            xaccTransSetDatePostedTS (ll_txn, &ts);
-
-        }
+        if (time_posted > time)
+            xaccTransSetDatePostedSecs (ll_txn, time_posted);
     }
 
     /* Create a split for the from_lot */
diff --git a/libgnucash/engine/policy.c b/libgnucash/engine/policy.c
index 81c0d94..506da09 100644
--- a/libgnucash/engine/policy.c
+++ b/libgnucash/engine/policy.c
@@ -114,7 +114,7 @@ DirectionPolicyGetSplit (GNCPolicy *pcy, GNCLot *lot, short reverse)
     gnc_numeric baln;
     Split *osplit;
     Transaction *otrans;
-    Timespec open_ts;
+    time64 open_time;
     Account* lot_account;
 
     if (!pcy || !lot || !gnc_lot_get_split_list(lot)) return NULL;
@@ -136,7 +136,7 @@ DirectionPolicyGetSplit (GNCPolicy *pcy, GNCLot *lot, short reverse)
        and the lot may end up too thin or too fat. */
     osplit = gnc_lot_get_latest_split (lot);
     otrans = osplit ? xaccSplitGetParent (osplit) : 0;
-    open_ts = xaccTransRetDatePostedTS (otrans);
+    open_time = xaccTransRetDatePosted (otrans);
 
     /* Walk over *all* splits in the account, till we find one that
      * hasn't been assigned to a lot.  Return that split.
@@ -151,15 +151,13 @@ DirectionPolicyGetSplit (GNCPolicy *pcy, GNCLot *lot, short reverse)
     {
         gboolean is_match;
         gboolean is_positive;
-        Timespec this_ts;
+        time64 this_time;
         split = node->data;
         if (split->lot) goto donext;
 
         /* Skip it if it's too early */
-        this_ts = xaccTransRetDatePostedTS ( xaccSplitGetParent (split));
-        if ((this_ts.tv_sec < open_ts.tv_sec) ||
-                ((this_ts.tv_sec == open_ts.tv_sec) &&
-                 (this_ts.tv_nsec < open_ts.tv_nsec)))
+        this_time = xaccTransRetDatePosted ( xaccSplitGetParent (split));
+        if (this_time < open_time)
         {
             if (reverse)
                 /* Going backwards, no point in looking further */
diff --git a/libgnucash/engine/test-core/test-engine-stuff.cpp b/libgnucash/engine/test-core/test-engine-stuff.cpp
index c7bca6a..9e65914 100644
--- a/libgnucash/engine/test-core/test-engine-stuff.cpp
+++ b/libgnucash/engine/test-core/test-engine-stuff.cpp
@@ -1420,16 +1420,10 @@ set_tran_random_string_from_array(
         (func)(trn, tmp_str);
 }
 
-
 static void
-trn_add_ran_timespec(Transaction *trn, void (*func)(Transaction*,
-                     const Timespec*))
+trn_add_ran_time (Transaction *trn, void (*func)(Transaction*, time64))
 {
-    Timespec *to_set;
-
-    to_set = get_random_timespec();
-    func(trn, to_set);
-    g_free(to_set);
+    func(trn, get_random_time());
 }
 
 
@@ -1471,8 +1465,8 @@ get_random_transaction_with_currency(QofBook *book,
     xaccTransSetNum(trans, numstr);
     set_tran_random_string_from_array(trans, xaccTransSetDescription,
                                       sane_descriptions);
-    trn_add_ran_timespec(trans, xaccTransSetDatePostedTS);
-    trn_add_ran_timespec(trans, xaccTransSetDateEnteredTS);
+    trn_add_ran_time(trans, xaccTransSetDatePostedSecs);
+    trn_add_ran_time(trans, xaccTransSetDateEnteredSecs);
 
     f = get_random_kvp_frame();
     qof_instance_set_slots (QOF_INSTANCE (trans), f);
@@ -1531,8 +1525,8 @@ make_random_changes_to_transaction (QofBook *book, Transaction *trans)
 
     set_tran_random_string (trans, xaccTransSetNum);
 
-    trn_add_ran_timespec (trans, xaccTransSetDatePostedTS);
-    trn_add_ran_timespec (trans, xaccTransSetDateEnteredTS);
+    trn_add_ran_time (trans, xaccTransSetDatePostedSecs);
+    trn_add_ran_time (trans, xaccTransSetDateEnteredSecs);
 
     set_tran_random_string (trans, xaccTransSetDescription);
 
@@ -2055,10 +2049,8 @@ make_trans_query (Transaction *trans, TestQueryTypes query_types)
         }
 
         {
-            Timespec ts;
-
-            xaccTransGetDatePostedTS (trans, &ts);
-            xaccQueryAddDateMatchTS (q, TRUE, ts, TRUE, ts, QOF_QUERY_AND);
+            time64 time = xaccTransRetDatePosted (trans);
+            xaccQueryAddDateMatchTT (q, TRUE, time, TRUE, time, QOF_QUERY_AND);
         }
 
         if (xaccSplitGetMemo(s) && *xaccSplitGetMemo(s) != '\0')
diff --git a/libgnucash/engine/test/utest-Split.cpp b/libgnucash/engine/test/utest-Split.cpp
index eafe1bb..23bff9b 100644
--- a/libgnucash/engine/test/utest-Split.cpp
+++ b/libgnucash/engine/test/utest-Split.cpp
@@ -1125,7 +1125,7 @@ test_xaccSplitOrder (Fixture *fixture, gconstpointer pData)
      * split-action based on book option.
      */
     o_split->parent = o_txn;
-    split->parent->date_posted = timespec_now ();
+    split->parent->date_posted = gnc_time (NULL);
     o_split->parent->date_posted = split->parent->date_posted;
 
     /* The book_use_split_action_for_num_field book option hasn't been set so it
@@ -1249,13 +1249,13 @@ test_xaccSplitOrderDateOnly (Fixture *fixture, gconstpointer pData)
     g_assert_cmpint (xaccSplitOrderDateOnly (split, o_split), ==, 1);
     split->parent = txn;
 
-    txn->date_posted = timespec_now ();
-    o_txn->date_posted = timespec_now ();
-    o_txn->date_posted.tv_sec -= 50;
+    txn->date_posted = gnc_time (nullptr);
+    o_txn->date_posted = gnc_time (nullptr);
+    o_txn->date_posted -= 50;
     g_assert_cmpint (xaccSplitOrderDateOnly (split, o_split), ==, 1);
-    o_txn->date_posted.tv_sec += 100;
+    o_txn->date_posted += 100;
     g_assert_cmpint (xaccSplitOrderDateOnly (split, o_split), ==, -1);
-    o_txn->date_posted.tv_sec -= 50;
+    o_txn->date_posted -= 50;
     g_assert_cmpint (xaccSplitOrderDateOnly (split, o_split), ==, -1);
 
     test_destroy (o_split);
diff --git a/libgnucash/engine/test/utest-Transaction.cpp b/libgnucash/engine/test/utest-Transaction.cpp
index c322c66..8af79d3 100644
--- a/libgnucash/engine/test/utest-Transaction.cpp
+++ b/libgnucash/engine/test/utest-Transaction.cpp
@@ -119,8 +119,8 @@ setup (Fixture *fixture, gconstpointer pData)
     QofBook *book = qof_book_new ();
     TransMockBackend *mbe = new TransMockBackend;
     Transaction *txn;
-    Timespec entered = gnc_dmy2timespec (20, 4, 2012);
-    Timespec posted = gnc_dmy2timespec (21, 4, 2012);
+    time64 entered = gnc_dmy2time64 (20, 4, 2012);
+    time64 posted = gnc_dmy2time64 (21, 4, 2012);
     auto frame = new KvpFrame ();
 
     qof_book_set_backend (book, mbe);
@@ -134,10 +134,8 @@ setup (Fixture *fixture, gconstpointer pData)
     fixture->acc2 = xaccMallocAccount (book);
     xaccAccountSetCommodity (fixture->acc1, fixture->comm);
     xaccAccountSetCommodity (fixture->acc2, fixture->curr);
-    txn->date_posted.tv_sec = posted.tv_sec;
-    txn->date_posted.tv_nsec = posted.tv_nsec;
-    txn->date_entered.tv_sec = entered.tv_sec;
-    txn->date_entered.tv_nsec = entered.tv_nsec;
+    txn->date_posted = posted;
+    txn->date_entered = entered;
     split1->memo = static_cast<char*>(CACHE_INSERT ("foo"));
     split1->action = static_cast<char*>(CACHE_INSERT ("bar"));
     split1->amount = gnc_numeric_create (100000, 1000);
@@ -343,10 +341,8 @@ test_gnc_transaction_init ()
     g_assert_cmpstr (txn->description, ==, "");
     g_assert (txn->common_currency == NULL);
     g_assert (txn->splits == NULL);
-    g_assert_cmpint (txn->date_entered.tv_sec, ==, 0);
-    g_assert_cmpint (txn->date_entered.tv_nsec, ==, 0);
-    g_assert_cmpint (txn->date_posted.tv_sec, ==, 0);
-    g_assert_cmpint (txn->date_posted.tv_nsec, ==, 0);
+    g_assert_cmpint (txn->date_entered, ==, 0);
+    g_assert_cmpint (txn->date_posted, ==, 0);
     g_assert_cmpint (txn->marker, ==, 0);
     g_assert (txn->orig == NULL);
 
@@ -416,10 +412,8 @@ test_gnc_transaction_set_get_property (Fixture *fixture, gconstpointer pData)
     g_assert_cmpstr (txn->num, ==, "");
     g_assert_cmpstr (txn->description, ==, "");
     g_assert (txn->common_currency == NULL);
-    g_assert_cmpint (txn->date_entered.tv_sec, ==, 0);
-    g_assert_cmpint (txn->date_entered.tv_nsec, ==, 0);
-    g_assert_cmpint (txn->date_posted.tv_sec, ==, 0);
-    g_assert_cmpint (txn->date_posted.tv_nsec, ==, 0);
+    g_assert_cmpint (txn->date_entered, ==, 0);
+    g_assert_cmpint (txn->date_posted, ==, 0);
     /* Kick up the edit counter to keep from committing */
     xaccTransBeginEdit (txn);
     g_object_set (G_OBJECT (txn),
@@ -433,8 +427,8 @@ test_gnc_transaction_set_get_property (Fixture *fixture, gconstpointer pData)
     g_assert_cmpstr (txn->num, ==, num);
     g_assert_cmpstr (txn->description, ==, desc);
     g_assert (txn->common_currency == curr);
-    g_assert (timespec_equal (&(txn->date_entered), &now));
-    g_assert (timespec_equal (&(txn->date_posted), &now));
+    g_assert (txn->date_entered == now.tv_sec);
+    g_assert (txn->date_posted == now.tv_sec);
 
     g_object_get (G_OBJECT (txn),
                   "num", &t_num,
@@ -447,13 +441,12 @@ test_gnc_transaction_set_get_property (Fixture *fixture, gconstpointer pData)
     g_assert_cmpstr (t_num, ==, num);
     g_assert_cmpstr (t_desc, ==, desc);
     g_assert (t_curr == curr);
-    g_assert (timespec_equal (t_entered, &now));
-    g_assert (timespec_equal (t_posted, &now));
+    g_assert (t_entered->tv_sec == now.tv_sec);
+    g_assert (t_posted->tv_sec == now.tv_sec);
     xaccTransRollbackEdit (txn);
     test_destroy (txn);
     test_destroy (curr);
     qof_book_destroy (book);
-    g_free (t_entered);
 }
 /* gnc_transaction_class_init
  * xaccInitTransaction
@@ -554,8 +547,8 @@ dupe_trans (const Transaction *from)// Local: 1:0:0
 static void
 test_dupe_trans (Fixture *fixture, gconstpointer pData)
 {
-    Timespec posted = gnc_dmy2timespec (12, 7, 2011);
-    Timespec entered = gnc_dmy2timespec (14, 7, 2011);
+    time64 posted = gnc_dmy2time64 (12, 7, 2011);
+    time64 entered = gnc_dmy2time64 (14, 7, 2011);
     Transaction *newtxn = NULL, *oldtxn = fixture->txn;
     QofBook *old_book = qof_instance_get_book (QOF_INSTANCE (oldtxn));
     GList *newnode, *oldnode = oldtxn->splits;
@@ -579,8 +572,8 @@ test_dupe_trans (Fixture *fixture, gconstpointer pData)
     }
     g_assert (newnode == NULL);
     g_assert (oldnode == NULL);
-    g_assert (timespec_equal (&(newtxn->date_posted), &posted));
-    g_assert (timespec_equal (&(newtxn->date_entered), &entered));
+    g_assert (newtxn->date_posted == posted);
+    g_assert (newtxn->date_entered == entered);
     g_assert (qof_instance_version_cmp (QOF_INSTANCE (newtxn),
                                         QOF_INSTANCE (oldtxn)) == 0);
     g_assert (newtxn->orig == NULL);
@@ -600,8 +593,8 @@ xaccTransClone (const Transaction *from)// C: 1  Local: 1:0:0
 static void
 test_xaccTransClone (Fixture *fixture, gconstpointer pData)
 {
-    Timespec posted = gnc_dmy2timespec (12, 7, 2011);
-    Timespec entered = gnc_dmy2timespec (14, 7, 2011);
+    time64 posted = gnc_dmy2time64 (12, 7, 2011);
+    time64 entered = gnc_dmy2time64 (14, 7, 2011);
     Transaction *newtxn = NULL, *oldtxn = fixture->txn;
     QofBook *old_book = qof_instance_get_book (QOF_INSTANCE (oldtxn));
     GList *newnode, *oldnode;
@@ -631,8 +624,8 @@ test_xaccTransClone (Fixture *fixture, gconstpointer pData)
     }
     g_assert (newnode == NULL);
     g_assert (oldnode == NULL);
-    g_assert (timespec_equal (&(newtxn->date_posted), &posted));
-    g_assert (timespec_equal (&(newtxn->date_entered), &entered));
+    g_assert (newtxn->date_posted == posted);
+    g_assert (newtxn->date_entered == entered);
     g_assert (qof_instance_version_cmp (QOF_INSTANCE (newtxn),
                                         QOF_INSTANCE (oldtxn)) == 0);
     g_assert_cmpint (qof_instance_get_version_check (newtxn), ==,
@@ -665,16 +658,16 @@ test_xaccTransCopyFromClipBoard (Fixture *fixture, gconstpointer pData)
     QofBook *book = qof_instance_get_book (QOF_INSTANCE (txn));
     Account *acc1 = xaccMallocAccount (book);
     Transaction *to_txn = xaccMallocTransaction (book);
-    Timespec now = timespec_now();
-    Timespec never = {0, 0};
+    time64 now = gnc_time (nullptr);
+    time64 never = 0;
     auto to_frame = to_txn->inst.kvp_data;
 
     xaccAccountSetCommodity (acc1, fixture->comm);
     xaccTransCopyFromClipBoard (txn, to_txn, fixture->acc1, acc1, FALSE);
     g_assert (gnc_commodity_equal (txn->common_currency,
                                    to_txn->common_currency));
-    g_assert (timespec_equal (&(to_txn->date_entered), &now));
-    g_assert (timespec_equal (&(to_txn->date_posted), &txn->date_posted));
+    g_assert (to_txn->date_entered == now);
+    g_assert (to_txn->date_posted == txn->date_posted);
     g_assert_cmpstr (txn->num, ==, to_txn->num);
     /* Notes also tests that KVP is copied */
     g_assert_cmpstr (xaccTransGetNotes (txn), ==, xaccTransGetNotes (to_txn));
@@ -692,15 +685,15 @@ test_xaccTransCopyFromClipBoard_no_start (Fixture *fixture, gconstpointer pData)
     QofBook *book = qof_instance_get_book (QOF_INSTANCE (txn));
     Account *acc1 = xaccMallocAccount (book);
     Transaction *to_txn = xaccMallocTransaction (book);
-    Timespec now = timespec_now();
-    Timespec never = {0, 0};
+    time64 now = gnc_time (nullptr);
+    time64 never = 0;
 
     xaccAccountSetCommodity (acc1, fixture->comm);
     xaccTransCopyFromClipBoard (txn, to_txn, fixture->acc1, acc1, TRUE);
     g_assert (gnc_commodity_equal (txn->common_currency,
                                    to_txn->common_currency));
-    g_assert (timespec_equal (&(to_txn->date_entered), &now));
-    g_assert (timespec_equal (&(to_txn->date_posted), &never));
+    g_assert (to_txn->date_entered == now);
+    g_assert (to_txn->date_posted == never);
     g_assert_cmpstr (to_txn->num, ==, txn->num);
     /* Notes also tests that KVP is copied */
     g_assert_cmpstr (xaccTransGetNotes (txn), ==, xaccTransGetNotes (to_txn));
@@ -736,10 +729,8 @@ test_xaccFreeTransaction (Fixture *fixture, gconstpointer pData)
     g_assert (txn->splits == NULL);
     g_assert_cmpint (GPOINTER_TO_INT(txn->num), ==, 1);
     g_assert (txn->description == NULL);
-    g_assert_cmpint (txn->date_entered.tv_sec, ==, 0);
-    g_assert_cmpint (txn->date_entered.tv_nsec, ==, 0);
-    g_assert_cmpint (txn->date_posted.tv_sec, ==, 0);
-    g_assert_cmpint (txn->date_posted.tv_nsec, ==, 0);
+    g_assert_cmpint (txn->date_entered, ==, 0);
+    g_assert_cmpint (txn->date_posted, ==, 0);
     g_assert_cmpint (GPOINTER_TO_INT(orig->num), ==, 1);
     g_assert (txn->orig == NULL);
     test_destroy (orig);
@@ -818,13 +809,13 @@ test_xaccTransEqual (Fixture *fixture, gconstpointer pData)
     g_assert (!xaccTransEqual (clone, txn0, TRUE, FALSE, TRUE, TRUE));
     g_assert_cmpint (check->hits, ==, 2);
 
-    gnc_timespec_to_iso8601_buff (clone->date_posted, posted);
-    gnc_timespec_to_iso8601_buff (clone->date_entered, entered);
+    gnc_time64_to_iso8601_buff (clone->date_posted, posted);
+    gnc_time64_to_iso8601_buff (clone->date_entered, entered);
     xaccTransBeginEdit (clone);
     cleanup->msg = g_strdup_printf (cleanup_fmt, clone->orig);
     /* This puts the value of the first split back, but leaves the amount changed */
     xaccTransSetCurrency (clone, fixture->curr);
-    clone->date_posted.tv_sec = txn0->date_entered.tv_sec;
+    clone->date_posted = txn0->date_entered;
     xaccTransCommitEdit (clone);
     g_free (cleanup->msg);
     g_free (check->msg);
@@ -834,8 +825,8 @@ test_xaccTransEqual (Fixture *fixture, gconstpointer pData)
 
     xaccTransBeginEdit (clone);
     cleanup->msg = g_strdup_printf (cleanup_fmt, clone->orig);
-    clone->date_posted.tv_sec = txn0->date_posted.tv_sec;
-    clone->date_entered.tv_sec = txn0->date_posted.tv_sec;
+    clone->date_posted = txn0->date_posted;
+    clone->date_entered = txn0->date_posted;
     xaccTransCommitEdit (clone);
     g_free (cleanup->msg);
     g_free (check->msg);
@@ -845,7 +836,7 @@ test_xaccTransEqual (Fixture *fixture, gconstpointer pData)
 
     xaccTransBeginEdit (clone);
     cleanup->msg = g_strdup_printf (cleanup_fmt, clone->orig);
-    clone->date_entered.tv_sec = txn0->date_entered.tv_sec;
+    clone->date_entered = txn0->date_entered;
     clone->num = g_strdup("123");
     xaccTransCommitEdit (clone);
     g_free (cleanup->msg);
@@ -1590,7 +1581,7 @@ test_xaccTransCommitEdit (void)
     gnc_commodity *comm = gnc_commodity_new (book, "Wildebeest Fund",
                           "FUND", "WBFXX", "", 1000);
 
-    Timespec posted = gnc_dmy2timespec (21, 4, 2012);
+    time64 posted = gnc_dmy2time64 (21, 4, 2012);
 
     auto sig_1_modify = test_signal_new (QOF_INSTANCE (split1),
                                QOF_EVENT_MODIFY, NULL);
@@ -1602,8 +1593,7 @@ test_xaccTransCommitEdit (void)
 
     xaccAccountSetCommodity (acc1, comm);
     xaccAccountSetCommodity (acc2, curr);
-    txn->date_posted.tv_sec = posted.tv_sec;
-    txn->date_posted.tv_nsec = posted.tv_nsec;
+    txn->date_posted = posted;
     split1->memo = static_cast<char*>(CACHE_INSERT ("foo"));
     split1->action = static_cast<char*>(CACHE_INSERT ("bar"));
     split1->amount = gnc_numeric_create (100000, 1000);
@@ -1626,7 +1616,7 @@ test_xaccTransCommitEdit (void)
     /* Setup's done, now test: */
     xaccTransCommitEdit (txn);
 
-    g_assert_cmpint (txn->date_entered.tv_sec, !=, 0);
+    g_assert_cmpint (txn->date_entered, !=, 0);
     /* Signals make sure that trans_cleanup_commit got called */
     g_assert_cmpint (test_signal_return_hits (sig_1_modify), ==, 1);
     g_assert_cmpint (test_signal_return_hits (sig_2_modify), ==, 1);
@@ -1659,13 +1649,13 @@ test_xaccTransRollbackEdit (Fixture *fixture, gconstpointer pData)
     Transaction *txn = fixture->txn;
     Transaction *orig = NULL;
     QofBook *book = qof_instance_get_book (txn);
-    Timespec new_post = timespec_now ();
-    Timespec new_entered = timespecCanonicalDayTime (timespec_now ());
-    Timespec orig_post = txn->date_posted;
-    Timespec orig_entered = txn->date_entered;
+    time64 new_post = gnc_time (nullptr);
+    time64 new_entered = time64CanonicalDayTime (new_post);
+    time64 orig_post = txn->date_posted;
+    time64 orig_entered = txn->date_entered;
     KvpFrame *base_frame = NULL;
     auto sig_account = test_signal_new (QOF_INSTANCE (fixture->acc1),
-                              GNC_EVENT_ITEM_CHANGED, NULL);
+            GNC_EVENT_ITEM_CHANGED, NULL);
     auto mbe = static_cast<TransMockBackend*>(qof_book_get_backend (book));
     auto split_00 = static_cast<Split*>(txn->splits->data);
     auto split_01 = static_cast<Split*>(txn->splits->next->data);
@@ -1705,8 +1695,8 @@ test_xaccTransRollbackEdit (Fixture *fixture, gconstpointer pData)
     g_assert_cmpstr (txn->description, ==, "Waldo Pepper");
     g_assert (txn->inst.kvp_data == base_frame);
     g_assert (txn->common_currency == fixture->curr);
-    g_assert (timespec_equal (&(txn->date_posted), &orig_post));
-    g_assert (timespec_equal (&(txn->date_entered), &orig_entered));
+    g_assert (txn->date_posted == orig_post);
+    g_assert (txn->date_entered == orig_entered);
     g_assert_cmpuint (test_signal_return_hits (sig_account), ==, 1);
     g_assert_cmpuint (g_list_length (txn->splits), ==, 2);
     g_assert_cmpint (GPOINTER_TO_INT(split_02->memo), ==, 1);
@@ -1771,14 +1761,14 @@ test_xaccTransOrder_num_action (Fixture *fixture, gconstpointer pData)
                      qof_instance_guid_compare (txnA, txnB));
     txnB->description = static_cast<char*>(CACHE_INSERT ("Salt Peanuts"));
     g_assert_cmpint (xaccTransOrder_num_action (txnA, NULL, txnB, NULL), >=, 1);
-    txnB->date_entered.tv_sec += 1;
+    txnB->date_entered += 1;
     g_assert_cmpint (xaccTransOrder_num_action (txnA, NULL, txnB, NULL), ==, -1);
     txnB->num = static_cast<char*>(CACHE_INSERT ("101"));
     g_assert_cmpint (xaccTransOrder_num_action (txnA, NULL, txnB, NULL), ==, 1);
     txnB->num = static_cast<char*>(CACHE_INSERT ("one-oh-one"));
     g_assert_cmpint (xaccTransOrder_num_action (txnA, NULL, txnB, NULL), ==, 1);
     g_assert_cmpint (xaccTransOrder_num_action (txnA, "24", txnB, "42"), ==, -1);
-    txnB->date_posted.tv_sec -= 1;
+    txnB->date_posted -= 1;
     g_assert_cmpint (xaccTransOrder_num_action (txnA, "24", txnB, "42"), ==, 1);
 
     fixture->func->xaccFreeTransaction (txnB);
@@ -1954,8 +1944,7 @@ test_xaccTransScrubGainsDate_no_dirty (GainsFixture *fixture,
 
     fixture->base.func->xaccTransScrubGainsDate (fixture->base.txn);
 
-    g_assert (!timespec_equal (&(fixture->base.txn->date_posted),
-                               &(fixture->gains_txn->date_posted)));
+    g_assert (fixture->base.txn->date_posted != fixture->gains_txn->date_posted);
     g_assert_cmphex (base_split->gains & GAINS_STATUS_DATE_DIRTY, ==, 0);
     g_assert_cmphex (base_split->gains_split->gains & GAINS_STATUS_DATE_DIRTY,
                      ==, 0);
@@ -1973,8 +1962,7 @@ test_xaccTransScrubGainsDate_base_dirty (GainsFixture *fixture,
 
     fixture->base.func->xaccTransScrubGainsDate (fixture->base.txn);
 
-    g_assert (timespec_equal (&(fixture->base.txn->date_posted),
-                              &(fixture->gains_txn->date_posted)));
+    g_assert (fixture->base.txn->date_posted == fixture->gains_txn->date_posted);
     g_assert_cmphex (base_split->gains & GAINS_STATUS_DATE_DIRTY, ==, 0);
     g_assert_cmphex (base_split->gains_split->gains & GAINS_STATUS_DATE_DIRTY,
                      ==, 0);
@@ -1992,8 +1980,7 @@ test_xaccTransScrubGainsDate_gains_dirty (GainsFixture *fixture,
 
     fixture->base.func->xaccTransScrubGainsDate (fixture->base.txn);
 
-    g_assert (timespec_equal (&(fixture->base.txn->date_posted),
-                              &(fixture->gains_txn->date_posted)));
+    g_assert (fixture->base.txn->date_posted == fixture->gains_txn->date_posted);
     g_assert_cmphex (base_split->gains & GAINS_STATUS_DATE_DIRTY, ==, 0);
     g_assert_cmphex (base_split->gains_split->gains & GAINS_STATUS_DATE_DIRTY,
                      ==, 0);

commit 9a86dd222bebaec341132f0d1ad8e25c0fea30f9
Author: lmat <dartme18 at gmail.com>
Date:   Fri Dec 29 16:07:08 2017 -0500

    gncInvoice uses time64

diff --git a/gnucash/gnome/dialog-invoice.c b/gnucash/gnome/dialog-invoice.c
index 83c9218..43c08bf 100644
--- a/gnucash/gnome/dialog-invoice.c
+++ b/gnucash/gnome/dialog-invoice.c
@@ -308,7 +308,7 @@ static void gnc_ui_to_invoice (InvoiceWindow *iw, GncInvoice *invoice)
     GtkTextBuffer* text_buffer;
     GtkTextIter start, end;
     gchar *text;
-    Timespec ts;
+    time64 time;
     gboolean is_credit_note = gncInvoiceGetIsCreditNote (invoice);
 
     if (iw->dialog_type == VIEW_INVOICE)
@@ -341,8 +341,8 @@ static void gnc_ui_to_invoice (InvoiceWindow *iw, GncInvoice *invoice)
                                 (GTK_EDITABLE (iw->billing_id_entry), 0, -1));
         gncInvoiceSetTerms (invoice, iw->terms);
 
-        ts = gnc_date_edit_get_date_ts (GNC_DATE_EDIT (iw->opened_date));
-        gncInvoiceSetDateOpened (invoice, ts);
+        time = gnc_date_edit_get_date (GNC_DATE_EDIT (iw->opened_date));
+        gncInvoiceSetDateOpened (invoice, time);
 
         gnc_owner_get_owner (iw->owner_choice, &(iw->owner));
         if (iw->job_choice)
@@ -948,7 +948,7 @@ gnc_invoice_post(InvoiceWindow *iw, struct post_invoice_params *post_params)
     else
         auto_pay = gnc_prefs_get_bool (GNC_PREFS_GROUP_BILL, GNC_PREF_AUTO_PAY);
 
-    gncInvoicePostToAccount (invoice, acc, &postdate, &ddue, memo, accumulate, auto_pay);
+    gncInvoicePostToAccount (invoice, acc, postdate.tv_sec, ddue.tv_sec, memo, accumulate, auto_pay);
 
 cleanup:
     gncInvoiceCommitEdit (invoice);
@@ -1747,8 +1747,8 @@ gnc_invoice_update_window (InvoiceWindow *iw, GtkWidget *widget)
         GtkTextBuffer* text_buffer;
         const char *string;
         gchar * tmp_string;
-        Timespec ts, ts_zero = {0, 0};
         Account *acct;
+        time64 time;
 
         gtk_entry_set_text (GTK_ENTRY (iw->id_entry), gncInvoiceGetID (invoice));
 
@@ -1763,15 +1763,15 @@ gnc_invoice_update_window (InvoiceWindow *iw, GtkWidget *widget)
             gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (iw->active_check),
                                           gncInvoiceGetActive (invoice));
 
-        ts = gncInvoiceGetDateOpened (invoice);
-        if (timespec_equal (&ts, &ts_zero))
+        time = gncInvoiceGetDateOpened (invoice);
+        if (!time)
         {
             gnc_date_edit_set_time (GNC_DATE_EDIT (iw->opened_date),
                                     gnc_time (NULL));
         }
         else
         {
-            gnc_date_edit_set_time_ts (GNC_DATE_EDIT (iw->opened_date), ts);
+            gnc_date_edit_set_time (GNC_DATE_EDIT (iw->opened_date), time);
         }
 
         /* fill in the terms text */
@@ -1816,8 +1816,8 @@ gnc_invoice_update_window (InvoiceWindow *iw, GtkWidget *widget)
              */
             can_unpost = TRUE;
 
-            ts = gncInvoiceGetDatePosted (invoice);
-            gnc_date_edit_set_time_ts (GNC_DATE_EDIT (iw->posted_date), ts);
+            time = gncInvoiceGetDatePosted (invoice);
+            gnc_date_edit_set_time (GNC_DATE_EDIT (iw->posted_date), time);
 
             tmp_string = gnc_account_get_full_name (acct);
             gtk_entry_set_text (GTK_ENTRY (acct_entry), tmp_string);
diff --git a/gnucash/gnome/dialog-payment.c b/gnucash/gnome/dialog-payment.c
index e11d07a..305c5fc 100644
--- a/gnucash/gnome/dialog-payment.c
+++ b/gnucash/gnome/dialog-payment.c
@@ -485,7 +485,6 @@ gnc_payment_window_fill_docs_list (PaymentWindow *pw)
         const gchar *doc_deb_str  = NULL;
         const gchar *doc_cred_str = NULL;
         GtkTreeIter iter;
-        Timespec doc_date;
         GncInvoice *document;
         gnc_numeric value = gnc_numeric_zero();
         gnc_numeric debit = gnc_numeric_zero();
@@ -497,17 +496,16 @@ gnc_payment_window_fill_docs_list (PaymentWindow *pw)
 
         /* Find the document's date or pre-payment date */
         if (document)
-            doc_date = gncInvoiceGetDatePosted (document);
+            doc_date_time = gncInvoiceGetDatePosted (document);
         else
         {
             /* Calculate the payment date based on the lot splits */
             Transaction *trans = xaccSplitGetParent (gnc_lot_get_latest_split (lot));
             if (trans)
-                doc_date = xaccTransRetDatePostedTS (trans);
+                doc_date_time = xaccTransRetDatePosted (trans);
             else
                 continue; /* No valid split in this lot, skip it */
         }
-        doc_date_time = timespecToTime64 (doc_date);
 
         /* Find the document type. No type means pre-payment in this case */
         if (document)
diff --git a/gnucash/gnome/gnc-plugin-business.c b/gnucash/gnome/gnc-plugin-business.c
index eb418b3..121bd48 100644
--- a/gnucash/gnome/gnc-plugin-business.c
+++ b/gnucash/gnome/gnc-plugin-business.c
@@ -957,18 +957,17 @@ static void
 gnc_plugin_business_cmd_test_init_data (GtkAction *action,
                                         GncMainWindowActionData *data)
 {
-    QofBook *book       = gnc_get_current_book();
+    QofBook *book           = gnc_get_current_book();
     GncCustomer *customer   = gncCustomerCreate(book);
-    GncAddress *address = gncCustomerGetAddr(customer);
-    GncInvoice *invoice = gncInvoiceCreate(book);
-    GncOwner *owner     = gncOwnerNew();
-    GncJob *job         = gncJobCreate(book);
-    Account *root       = gnc_book_get_root_account(book);
-    Account *inc_acct   = xaccMallocAccount(book);
-    Account *bank_acct  = xaccMallocAccount(book);
-    Account *tax_acct   = xaccMallocAccount(book);
-    Account *ar_acct    = xaccMallocAccount(book);
-    Timespec now;
+    GncAddress *address     = gncCustomerGetAddr(customer);
+    GncInvoice *invoice     = gncInvoiceCreate(book);
+    GncOwner *owner         = gncOwnerNew();
+    GncJob *job             = gncJobCreate(book);
+    Account *root           = gnc_book_get_root_account(book);
+    Account *inc_acct       = xaccMallocAccount(book);
+    Account *bank_acct      = xaccMallocAccount(book);
+    Account *tax_acct       = xaccMallocAccount(book);
+    Account *ar_acct        = xaccMallocAccount(book);
 
     // Create Customer
     gncCustomerSetID(customer, "000001");
@@ -983,10 +982,9 @@ gnc_plugin_business_cmd_test_init_data (GtkAction *action,
     gncOwnerInitCustomer(owner, customer);
 
     // Create the Invoice
-    timespecFromTime64(&now, time(NULL));
     gncInvoiceSetID(invoice, "000012");
     gncInvoiceSetOwner(invoice, owner);
-    gncInvoiceSetDateOpened(invoice, now);
+    gncInvoiceSetDateOpened(invoice, gnc_time (NULL));
     gncInvoiceSetCurrency(invoice, gnc_default_currency());
 
     // Create the Job
diff --git a/gnucash/register/ledger-core/gncEntryLedger.c b/gnucash/register/ledger-core/gncEntryLedger.c
index c8ac458..b3ea148 100644
--- a/gnucash/register/ledger-core/gncEntryLedger.c
+++ b/gnucash/register/ledger-core/gncEntryLedger.c
@@ -566,7 +566,7 @@ void gnc_entry_ledger_set_default_invoice (GncEntryLedger *ledger,
      * to understand why.
      */
     if (gncInvoiceGetOwnerType (invoice) == GNC_OWNER_VENDOR)
-        ledger->last_date_entered = timespec_to_gdate(gncInvoiceGetDateOpened (invoice));
+        ledger->last_date_entered = time64_to_gdate(gncInvoiceGetDateOpened (invoice));
 
     if (!ledger->query && invoice)
         create_invoice_query (ledger);
diff --git a/libgnucash/backend/xml/gnc-invoice-xml-v2.cpp b/libgnucash/backend/xml/gnc-invoice-xml-v2.cpp
index d2f2e01..1d3aef2 100644
--- a/libgnucash/backend/xml/gnc-invoice-xml-v2.cpp
+++ b/libgnucash/backend/xml/gnc-invoice-xml-v2.cpp
@@ -81,17 +81,17 @@ maybe_add_string (xmlNodePtr ptr, const char* tag, const char* str)
 }
 
 static void
-maybe_add_timespec (xmlNodePtr ptr, const char* tag, Timespec ts)
+maybe_add_time64 (xmlNodePtr ptr, const char* tag, time64 time)
 {
-    if (ts.tv_sec)
-        xmlAddChild (ptr, time64_to_dom_tree (tag, ts.tv_sec));
+    if (time)
+        xmlAddChild (ptr, time64_to_dom_tree (tag, time));
 }
 
 static xmlNodePtr
 invoice_dom_tree_create (GncInvoice* invoice)
 {
     xmlNodePtr ret;
-    Timespec ts;
+    time64 time;
     Transaction* txn;
     GNCLot* lot;
     Account* acc;
@@ -111,11 +111,10 @@ invoice_dom_tree_create (GncInvoice* invoice)
     xmlAddChild (ret, gnc_owner_to_dom_tree (invoice_owner_string,
                                              gncInvoiceGetOwner (invoice)));
 
-    ts = gncInvoiceGetDateOpened (invoice);
-    xmlAddChild (ret, time64_to_dom_tree (invoice_opened_string, ts.tv_sec));
+    time = gncInvoiceGetDateOpened (invoice);
+    xmlAddChild (ret, time64_to_dom_tree (invoice_opened_string, time));
 
-    maybe_add_timespec (ret, invoice_posted_string,
-                        gncInvoiceGetDatePosted (invoice));
+    maybe_add_time64 (ret, invoice_posted_string, gncInvoiceGetDatePosted (invoice));
 
     term = gncInvoiceGetTerms (invoice);
     if (term)
@@ -185,14 +184,12 @@ set_string (xmlNodePtr node, GncInvoice* invoice,
 }
 
 static inline gboolean
-set_timespec (xmlNodePtr node, GncInvoice* invoice,
-              void (*func) (GncInvoice* invoice, Timespec ts))
+set_time64 (xmlNodePtr node, GncInvoice* invoice,
+              void (*func) (GncInvoice* invoice, time64 time))
 {
     time64 time = dom_tree_to_time64 (node);
     if (!dom_tree_valid_time64 (time, node->name)) return FALSE;
-
-    Timespec ts = {time, 0};
-    func (invoice, ts);
+    func (invoice, time);
     return TRUE;
 }
 
@@ -248,16 +245,14 @@ static gboolean
 invoice_opened_handler (xmlNodePtr node, gpointer invoice_pdata)
 {
     struct invoice_pdata* pdata = static_cast<decltype (pdata)> (invoice_pdata);
-
-    return set_timespec (node, pdata->invoice, gncInvoiceSetDateOpened);
+    return set_time64 (node, pdata->invoice, gncInvoiceSetDateOpened);
 }
 
 static gboolean
 invoice_posted_handler (xmlNodePtr node, gpointer invoice_pdata)
 {
     struct invoice_pdata* pdata = static_cast<decltype (pdata)> (invoice_pdata);
-
-    return set_timespec (node, pdata->invoice, gncInvoiceSetDatePosted);
+    return set_time64 (node, pdata->invoice, gncInvoiceSetDatePosted);
 }
 
 static gboolean
diff --git a/libgnucash/engine/Transaction.c b/libgnucash/engine/Transaction.c
index dfc9107..a541d40 100644
--- a/libgnucash/engine/Transaction.c
+++ b/libgnucash/engine/Transaction.c
@@ -2056,6 +2056,13 @@ xaccTransSetDate (Transaction *trans, int day, int mon, int year)
 }
 
 void
+xaccTransSetDateDue (Transaction * trans, time64 time)
+{
+    Timespec ts_send = {time, 0};
+    xaccTransSetDateDueTS (trans, &ts_send);
+}
+
+void
 xaccTransSetDateDueTS (Transaction *trans, const Timespec *ts)
 {
     GValue v = G_VALUE_INIT;
diff --git a/libgnucash/engine/Transaction.h b/libgnucash/engine/Transaction.h
index 6104633..2ad3123 100644
--- a/libgnucash/engine/Transaction.h
+++ b/libgnucash/engine/Transaction.h
@@ -640,6 +640,7 @@ void          xaccTransSetDateEnteredTS (Transaction *trans,
 
 /** Dates and txn-type for A/R and A/P "invoice" postings */
 void	      xaccTransSetDateDueTS (Transaction *trans, const Timespec *ts);
+void          xaccTransSetDateDue (Transaction * trans, time64 time);
 
 /** Retrieve the posted date of the transaction. The posted date is
     the date when this transaction was posted at the bank. (Although
diff --git a/libgnucash/engine/gncInvoice.c b/libgnucash/engine/gncInvoice.c
index 670c344..139f932 100644
--- a/libgnucash/engine/gncInvoice.c
+++ b/libgnucash/engine/gncInvoice.c
@@ -61,8 +61,8 @@ struct _gncInvoice
     GncOwner      owner;
     GncOwner      billto;
     GncJob        *job;
-    Timespec      date_opened;
-    Timespec      date_posted;
+    time64      date_opened;
+    time64      date_posted;
 
     gnc_numeric   to_charge_amount;
 
@@ -481,23 +481,23 @@ qofInvoiceSetBillTo (GncInvoice *invoice, QofInstance *ent)
 void gncInvoiceSetDateOpenedGDate (GncInvoice *invoice, const GDate *date)
 {
     g_assert (date);
-    gncInvoiceSetDateOpened(invoice, timespecCanonicalDayTime(gdate_to_timespec(*date)));
+    gncInvoiceSetDateOpened(invoice, time64CanonicalDayTime(gdate_to_time64 (*date)));
 }
 
-void gncInvoiceSetDateOpened (GncInvoice *invoice, Timespec date)
+void gncInvoiceSetDateOpened (GncInvoice *invoice, time64 date)
 {
     if (!invoice) return;
-    if (timespec_equal (&invoice->date_opened, &date)) return;
+    if (date == invoice->date_opened) return;
     gncInvoiceBeginEdit (invoice);
     invoice->date_opened = date;
     mark_invoice (invoice);
     gncInvoiceCommitEdit (invoice);
 }
 
-void gncInvoiceSetDatePosted (GncInvoice *invoice, Timespec date)
+void gncInvoiceSetDatePosted (GncInvoice *invoice, time64 date)
 {
     if (!invoice) return;
-    if (timespec_equal (&invoice->date_posted, &date)) return;
+    if (date == invoice->date_posted) return;
     gncInvoiceBeginEdit (invoice);
     invoice->date_posted = date;
     mark_invoice (invoice);
@@ -805,52 +805,25 @@ qofInvoiceGetBillTo (GncInvoice *invoice)
     return QOF_INSTANCE(billto);
 }
 
-Timespec gncInvoiceGetDateOpened (const GncInvoice *invoice)
+time64 gncInvoiceGetDateOpened (const GncInvoice *invoice)
 {
-    Timespec ts;
-    ts.tv_sec = 0;
-    ts.tv_nsec = 0;
-    if (!invoice) return ts;
+    if (!invoice) return 0;
     return invoice->date_opened;
 }
 
-Timespec gncInvoiceGetDatePosted (const GncInvoice *invoice)
+time64 gncInvoiceGetDatePosted (const GncInvoice *invoice)
 {
-    Timespec ts;
-    ts.tv_sec = 0;
-    ts.tv_nsec = 0;
-    if (!invoice) return ts;
+    if (!invoice) return 0;
     return invoice->date_posted;
 }
 
-Timespec gncInvoiceGetDateDue (const GncInvoice *invoice)
+time64 gncInvoiceGetDateDue (const GncInvoice *invoice)
 {
     Transaction *txn;
-    Timespec ts;
-    ts.tv_sec = 0;
-    ts.tv_nsec = 0;
-    if (!invoice) return ts;
-    txn = gncInvoiceGetPostedTxn (invoice);
-    if (!txn) return ts;
-    return xaccTransRetDateDueTS (txn);
-}
-
-time64 gncInvoiceGetDateOpenedTT (const GncInvoice *invoice)
-{
     if (!invoice) return 0;
-    return invoice->date_opened.tv_sec;
-}
-
-time64 gncInvoiceGetDatePostedTT (const GncInvoice *invoice)
-{
-    if (!invoice) return 0;
-    return invoice->date_posted.tv_sec;
-}
-
-time64 gncInvoiceGetDateDueTT (const GncInvoice *invoice)
-{
-    if (!invoice) return 0;
-    return gncInvoiceGetDateDue (invoice).tv_sec;
+    txn = gncInvoiceGetPostedTxn (invoice);
+    if (!txn) return 0;
+    return xaccTransRetDateDue (txn);
 }
 
 GncBillTerm * gncInvoiceGetTerms (const GncInvoice *invoice)
@@ -1384,7 +1357,7 @@ static gboolean gncInvoicePostAddSplit (QofBook *book,
 }
 
 Transaction * gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
-                                       Timespec *post_date, Timespec *due_date,
+                                       time64 post_date, time64 due_date,
                                        const char * memo, gboolean accumulatesplits,
                                        gboolean autopay)
 {
@@ -1446,14 +1419,10 @@ Transaction * gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
 
     /* Entered and Posted at date */
     xaccTransSetDateEnteredSecs (txn, gnc_time (NULL));
-    if (post_date)
-    {
-        xaccTransSetDatePostedTS (txn, post_date);
-        gncInvoiceSetDatePosted (invoice, *post_date);
-    }
+    xaccTransSetDatePostedSecs (txn, post_date);
+    gncInvoiceSetDatePosted (invoice, post_date);
 
-    if (due_date)
-        xaccTransSetDateDueTS (txn, due_date);
+    xaccTransSetDateDue (txn, due_date);
 
     /* Iterate through the entries; sum up everything for each account.
      * then create the appropriate splits in this txn.
@@ -1749,7 +1718,7 @@ gncInvoiceUnpost (GncInvoice *invoice, gboolean reset_tax_tables)
     invoice->posted_acc = NULL;
     invoice->posted_txn = NULL;
     invoice->posted_lot = NULL;
-    invoice->date_posted.tv_sec = invoice->date_posted.tv_nsec = 0;
+    invoice->date_posted = 0;
 
     /* if we've been asked to reset the tax tables, then do so */
     if (reset_tax_tables)
@@ -1857,12 +1826,13 @@ void gncInvoiceAutoApplyPayments (GncInvoice *invoice)
 void
 gncInvoiceApplyPayment (const GncInvoice *invoice, Transaction *txn,
                         Account *xfer_acc, gnc_numeric amount,
-                        gnc_numeric exch, Timespec date,
+                        gnc_numeric exch, time64 date,
                         const char *memo, const char *num)
 {
     GNCLot *payment_lot;
     GList *selected_lots = NULL;
     const GncOwner *owner;
+    Timespec ts_pass = {date,0};
 
     /* Verify our arguments */
     if (!invoice || !gncInvoiceIsPosted (invoice) || !xfer_acc) return;
@@ -1872,7 +1842,7 @@ gncInvoiceApplyPayment (const GncInvoice *invoice, Transaction *txn,
 
     /* Create a lot for this payment */
     payment_lot = gncOwnerCreatePaymentLot (owner, &txn, invoice->posted_acc, xfer_acc,
-                                            amount, exch, date, memo, num);
+                                            amount, exch, ts_pass, memo, num);
 
     /* Select the invoice as only payment candidate */
     selected_lots = g_list_prepend (selected_lots, invoice->posted_lot);
@@ -1883,17 +1853,15 @@ gncInvoiceApplyPayment (const GncInvoice *invoice, Transaction *txn,
     gncOwnerAutoApplyPaymentsWithLots (owner, selected_lots);
 }
 
-static gboolean gncInvoiceDateExists (const Timespec *date)
+static gboolean gncInvoiceDateExists (time64 date)
 {
-    g_return_val_if_fail (date, FALSE);
-    if (date->tv_sec || date->tv_nsec) return TRUE;
-    return FALSE;
+    return date;
 }
 
 gboolean gncInvoiceIsPosted (const GncInvoice *invoice)
 {
     if (!invoice) return FALSE;
-    return gncInvoiceDateExists (&(invoice->date_posted));
+    return gncInvoiceDateExists (invoice->date_posted);
 }
 
 gboolean gncInvoiceIsPaid (const GncInvoice *invoice)
@@ -1941,13 +1909,8 @@ int gncInvoiceCompare (const GncInvoice *a, const GncInvoice *b)
 
     compare = g_strcmp0 (a->id, b->id);
     if (compare) return compare;
-
-    compare = timespec_cmp (&(a->date_opened), &(b->date_opened));
-    if (compare) return compare;
-
-    compare = timespec_cmp (&(a->date_posted), &(b->date_posted));
-    if (compare) return compare;
-
+    if (a->date_opened != b->date_opened) return a->date_opened - b->date_opened;
+    if (a->date_posted != b->date_posted) return a->date_posted - b->date_posted;
     return qof_instance_guid_compare(a, b);
 }
 
@@ -2033,8 +1996,8 @@ gboolean gncInvoiceEqual(const GncInvoice *a, const GncInvoice *b)
     GList       *prices;
     GncOwner    owner;
     GncOwner    billto;
-    Timespec    date_opened;
-    Timespec    date_posted;
+    time64    date_opened;
+    time64    date_posted;
 
     gnc_numeric	to_charge_amount;
 #endif
diff --git a/libgnucash/engine/gncInvoice.h b/libgnucash/engine/gncInvoice.h
index 6585898..1b5b65a 100644
--- a/libgnucash/engine/gncInvoice.h
+++ b/libgnucash/engine/gncInvoice.h
@@ -101,10 +101,10 @@ GncInvoice *gncInvoiceCopy (const GncInvoice *other_invoice);
 void gncInvoiceSetID (GncInvoice *invoice, const char *id);
 void gncInvoiceSetOwner (GncInvoice *invoice, GncOwner *owner);
 /** Set the DateOpened using a GDate argument. (Note: Internally this stores
-the date in a Timespec as created through timespecCanonicalDayTime()). */
+the date in a time64 as created through timespecCanonicalDayTime()). */
 void gncInvoiceSetDateOpenedGDate (GncInvoice *invoice, const GDate *date);
-void gncInvoiceSetDateOpened (GncInvoice *invoice, Timespec date);
-void gncInvoiceSetDatePosted (GncInvoice *invoice, Timespec date);
+void gncInvoiceSetDateOpened (GncInvoice *invoice, time64 date);
+void gncInvoiceSetDatePosted (GncInvoice *invoice, time64 date);
 void gncInvoiceSetTerms (GncInvoice *invoice, GncBillTerm *terms);
 void gncInvoiceSetBillingID (GncInvoice *invoice, const char *billing_id);
 void gncInvoiceSetNotes (GncInvoice *invoice, const char *notes);
@@ -137,12 +137,9 @@ void gncInvoiceRemoveEntries (GncInvoice *invoice);
  @{ */
 const char * gncInvoiceGetID (const GncInvoice *invoice);
 const GncOwner * gncInvoiceGetOwner (const GncInvoice *invoice);
-Timespec gncInvoiceGetDateOpened (const GncInvoice *invoice);
-time64 gncInvoiceGetDateOpenedTT (const GncInvoice *invoice);
-Timespec gncInvoiceGetDatePosted (const GncInvoice *invoice);
-time64 gncInvoiceGetDatePostedTT (const GncInvoice *invoice);
-Timespec gncInvoiceGetDateDue (const GncInvoice *invoice);
-time64 gncInvoiceGetDateDueTT (const GncInvoice *invoice);
+time64 gncInvoiceGetDateOpened (const GncInvoice *invoice);
+time64 gncInvoiceGetDatePosted (const GncInvoice *invoice);
+time64 gncInvoiceGetDateDue (const GncInvoice *invoice);
 GncBillTerm * gncInvoiceGetTerms (const GncInvoice *invoice);
 const char * gncInvoiceGetBillingID (const GncInvoice *invoice);
 const char * gncInvoiceGetNotes (const GncInvoice *invoice);
@@ -212,7 +209,7 @@ GHashTable *gncInvoiceGetForeignCurrencies (const GncInvoice *invoice);
  */
 Transaction *
 gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
-                         Timespec *posted_date, Timespec *due_date,
+                         time64 posted_date, time64 due_date,
                          const char *memo, gboolean accumulatesplits,
                          gboolean autopay);
 
@@ -253,7 +250,7 @@ gncInvoiceAutoApplyPayments (GncInvoice *invoice);
 void
 gncInvoiceApplyPayment (const GncInvoice *invoice, Transaction *txn,
                         Account *xfer_acc, gnc_numeric amount,
-                        gnc_numeric exch, Timespec date,
+                        gnc_numeric exch, time64 date,
                         const char *memo, const char *num);
 
 
diff --git a/libgnucash/engine/gncOwner.c b/libgnucash/engine/gncOwner.c
index c6616c5..2aad3c2 100644
--- a/libgnucash/engine/gncOwner.c
+++ b/libgnucash/engine/gncOwner.c
@@ -704,7 +704,7 @@ gint
 gncOwnerLotsSortFunc (GNCLot *lotA, GNCLot *lotB)
 {
     GncInvoice *ia, *ib;
-    Timespec da, db;
+    time64 da, db;
 
     ia = gncInvoiceGetInvoiceFromLot (lotA);
     ib = gncInvoiceGetInvoiceFromLot (lotB);
@@ -712,14 +712,14 @@ gncOwnerLotsSortFunc (GNCLot *lotA, GNCLot *lotB)
     if (ia)
         da = gncInvoiceGetDateDue (ia);
     else
-        da = xaccTransRetDatePostedTS (xaccSplitGetParent (gnc_lot_get_earliest_split (lotA)));
+        da = xaccTransRetDatePostedTS (xaccSplitGetParent (gnc_lot_get_earliest_split (lotA))).tv_sec;
 
     if (ib)
         db = gncInvoiceGetDateDue (ib);
     else
-        db = xaccTransRetDatePostedTS (xaccSplitGetParent (gnc_lot_get_earliest_split (lotB)));
+        db = xaccTransRetDatePostedTS (xaccSplitGetParent (gnc_lot_get_earliest_split (lotB))).tv_sec;
 
-    return timespec_cmp (&da, &db);
+    return (da > db) - (da < db);
 }
 
 GNCLot *
diff --git a/libgnucash/engine/test/utest-Invoice.c b/libgnucash/engine/test/utest-Invoice.c
index a55104d..fe8eb7b 100644
--- a/libgnucash/engine/test/utest-Invoice.c
+++ b/libgnucash/engine/test/utest-Invoice.c
@@ -69,7 +69,8 @@ static void
 test_invoice_post ( Fixture *fixture, gconstpointer pData )
 {
     GncInvoice *invoice = gncInvoiceCreate(fixture->book);
-    Timespec ts1 = timespec_now(), ts2 = ts1;
+    time64 ts1 = gnc_time(NULL);
+    time64 ts2 = ts1;
     g_assert(invoice);
     g_assert(!gncInvoiceGetIsCreditNote(invoice));
     g_assert(gncInvoiceGetActive(invoice));
@@ -81,7 +82,7 @@ test_invoice_post ( Fixture *fixture, gconstpointer pData )
 
     g_test_message( "Will now post the invoice" );
     g_assert(!gncInvoiceIsPosted(invoice));
-    gncInvoicePostToAccount(invoice, fixture->account, &ts1, &ts2, "memo", TRUE, FALSE);
+    gncInvoicePostToAccount(invoice, fixture->account, ts1, ts2, "memo", TRUE, FALSE);
     g_assert(gncInvoiceIsPosted(invoice));
 
     gncInvoiceUnpost(invoice, TRUE);

commit 598cb6d8615a93f1a812971e3fe906646252fb4f
Author: lmat <dartme18 at gmail.com>
Date:   Fri Dec 29 14:46:04 2017 -0500

    gncEntry members timespec->time64

diff --git a/gnucash/gnome/dialog-invoice.c b/gnucash/gnome/dialog-invoice.c
index f92c0ba..83c9218 100644
--- a/gnucash/gnome/dialog-invoice.c
+++ b/gnucash/gnome/dialog-invoice.c
@@ -724,14 +724,12 @@ gnc_dialog_post_invoice(InvoiceWindow *iw, char *message,
     if (entries && ((gncInvoiceGetOwnerType (invoice) == GNC_OWNER_VENDOR) ||
                     (gncInvoiceGetOwnerType (invoice) == GNC_OWNER_EMPLOYEE)))
     {
-        *postdate = gncEntryGetDate ((GncEntry*)entries->data);
+        postdate->tv_sec = gncEntryGetDate ((GncEntry*)entries->data);
         for (entries_iter = entries; entries_iter != NULL; entries_iter = g_list_next(entries_iter))
         {
-            Timespec entrydate;
-
-            entrydate = gncEntryGetDate ((GncEntry*)entries_iter->data);
-            if (timespec_cmp(&entrydate, postdate) > 0)
-                *postdate = entrydate;
+            time64 entrydate = gncEntryGetDate ((GncEntry*)entries_iter->data);
+            if (entrydate > postdate->tv_sec)
+                postdate->tv_sec = entrydate;
         }
     }
 
diff --git a/gnucash/register/ledger-core/gncEntryLedger.c b/gnucash/register/ledger-core/gncEntryLedger.c
index 8a75530..c8ac458 100644
--- a/gnucash/register/ledger-core/gncEntryLedger.c
+++ b/gnucash/register/ledger-core/gncEntryLedger.c
@@ -944,7 +944,7 @@ gnc_entry_ledger_duplicate_current_entry (GncEntryLedger *ledger)
 
         /* We also must set a new DateEntered on the new entry
          * because otherwise the ordering is not deterministic */
-        gncEntrySetDateEntered (new_entry, timespec_now());
+        gncEntrySetDateEntered (new_entry, gnc_time (NULL));
 
         /* Set the hint for where to display on the refresh */
         ledger->hint_entry = new_entry;
@@ -1017,7 +1017,7 @@ void gnc_entry_ledger_move_current_entry_updown (GncEntryLedger *ledger,
      * up the current sort ordering from here, so I cowardly refuse to
      * tweak the EntryDate in this case. */
     {
-        Timespec t1, t2;
+        time64 t1, t2;
         GDate d1 = gncEntryGetDateGDate(current),
               d2 = gncEntryGetDateGDate(target);
         if (g_date_compare(&d1, &d2) != 0)
@@ -1029,7 +1029,7 @@ void gnc_entry_ledger_move_current_entry_updown (GncEntryLedger *ledger,
         code used the timespec at the start of day. */
         t1 = gncEntryGetDate(current);
         t2 = gncEntryGetDate(target);
-        if (!timespec_equal(&t1, &t2))
+        if (t1 != t2)
         {
             /* Timespecs are not equal, even though the GDates were equal? Then
             we set the GDates again. This will force the timespecs to be equal
@@ -1048,12 +1048,12 @@ void gnc_entry_ledger_move_current_entry_updown (GncEntryLedger *ledger,
     /* Swap the date-entered of both entries. That's already
      * sufficient! */
     {
-        Timespec time_current = gncEntryGetDateEntered(current);
-        Timespec time_target = gncEntryGetDateEntered(target);
+        time64 time_current = gncEntryGetDateEntered(current);
+        time64 time_target = gncEntryGetDateEntered(target);
 
         /* Special treatment for identical times (potentially caused
          * by the "duplicate entry" command) */
-        if (timespec_equal(&time_current, &time_target))
+        if (time_current == time_target)
         {
             /*g_warning("Surprise - both DateEntered are equal.");*/
             /* We just increment the DateEntered of the previously
@@ -1061,9 +1061,9 @@ void gnc_entry_ledger_move_current_entry_updown (GncEntryLedger *ledger,
              * issues if multiple entries had this problem, but
              * whatever. */
             if (move_up)
-                time_current.tv_sec++;
+                ++time_current;
             else
-                time_target.tv_sec++;
+                ++time_target;
         }
 
         /* Write the new DateEntered. */
diff --git a/gnucash/register/ledger-core/gncEntryLedgerControl.c b/gnucash/register/ledger-core/gncEntryLedgerControl.c
index cc93fb1..c95f05a 100644
--- a/gnucash/register/ledger-core/gncEntryLedgerControl.c
+++ b/gnucash/register/ledger-core/gncEntryLedgerControl.c
@@ -90,10 +90,8 @@ gnc_entry_ledger_save (GncEntryLedger *ledger, gboolean do_commit)
 
     if (entry == blank_entry)
     {
-        Timespec ts;
-        ts.tv_sec = gnc_time (NULL);
-        ts.tv_nsec = 0;
-        gncEntrySetDateEntered (blank_entry, ts);
+        time64 time = gnc_time (NULL);
+        gncEntrySetDateEntered (blank_entry, time);
 
         switch (ledger->type)
         {
diff --git a/gnucash/register/ledger-core/gncEntryLedgerModel.c b/gnucash/register/ledger-core/gncEntryLedgerModel.c
index e62d109..ef47c13 100644
--- a/gnucash/register/ledger-core/gncEntryLedgerModel.c
+++ b/gnucash/register/ledger-core/gncEntryLedgerModel.c
@@ -187,11 +187,11 @@ static const char * get_date_entry (VirtualLocation virt_loc,
 {
     GncEntryLedger *ledger = user_data;
     GncEntry *entry;
-    Timespec ts;
+    Timespec ts = {0,0};
 
     entry = gnc_entry_ledger_get_entry (ledger, virt_loc.vcell_loc);
 
-    ts = gncEntryGetDate (entry);
+    ts.tv_sec = gncEntryGetDate (entry);
     return gnc_print_date (ts);
 }
 
diff --git a/libgnucash/backend/xml/gnc-entry-xml-v2.cpp b/libgnucash/backend/xml/gnc-entry-xml-v2.cpp
index 50a1241..f87be3f 100644
--- a/libgnucash/backend/xml/gnc-entry-xml-v2.cpp
+++ b/libgnucash/backend/xml/gnc-entry-xml-v2.cpp
@@ -111,7 +111,6 @@ static xmlNodePtr
 entry_dom_tree_create (GncEntry* entry)
 {
     xmlNodePtr ret;
-    Timespec ts;
     Account* acc;
     GncTaxTable* taxtable;
     GncOrder* order;
@@ -123,11 +122,11 @@ entry_dom_tree_create (GncEntry* entry)
     xmlAddChild (ret, guid_to_dom_tree (entry_guid_string,
                                         qof_instance_get_guid (QOF_INSTANCE (entry))));
 
-    ts = gncEntryGetDate (entry);
-    xmlAddChild (ret, time64_to_dom_tree (entry_date_string, ts.tv_sec));
+    auto time = gncEntryGetDate (entry);
+    xmlAddChild (ret, time64_to_dom_tree (entry_date_string, time));
 
-    ts = gncEntryGetDateEntered (entry);
-    xmlAddChild (ret, time64_to_dom_tree (entry_dateentered_string, ts.tv_sec));
+    time = gncEntryGetDateEntered (entry);
+    xmlAddChild (ret, time64_to_dom_tree (entry_dateentered_string, time));
 
     maybe_add_string (ret, entry_description_string,
                       gncEntryGetDescription (entry));
@@ -241,14 +240,12 @@ set_string (xmlNodePtr node, GncEntry* entry,
 }
 
 static inline gboolean
-set_timespec (xmlNodePtr node, GncEntry* entry,
-              void (*func) (GncEntry* entry, Timespec ts))
+set_time64 (xmlNodePtr node, GncEntry* entry,
+              void (*func) (GncEntry* entry, time64 ts))
 {
     time64 time = dom_tree_to_time64 (node);
     if (!dom_tree_valid_time64 (time, node->name)) return FALSE;
-
-    Timespec ts = {time, 0};
-    func (entry, ts);
+    func (entry, time);
     return TRUE;
 }
 
@@ -351,16 +348,14 @@ static gboolean
 entry_date_handler (xmlNodePtr node, gpointer entry_pdata)
 {
     struct entry_pdata* pdata = static_cast<decltype (pdata)> (entry_pdata);
-
-    return set_timespec (node, pdata->entry, gncEntrySetDate);
+    return set_time64 (node, pdata->entry, gncEntrySetDate);
 }
 
 static gboolean
 entry_dateentered_handler (xmlNodePtr node, gpointer entry_pdata)
 {
     struct entry_pdata* pdata = static_cast<decltype (pdata)> (entry_pdata);
-
-    return set_timespec (node, pdata->entry, gncEntrySetDateEntered);
+    return set_time64 (node, pdata->entry, gncEntrySetDateEntered);
 }
 
 static gboolean
diff --git a/libgnucash/engine/gnc-date.cpp b/libgnucash/engine/gnc-date.cpp
index b46024c..a88604f 100644
--- a/libgnucash/engine/gnc-date.cpp
+++ b/libgnucash/engine/gnc-date.cpp
@@ -1405,6 +1405,13 @@ gnc_gdate_set_time64 (GDate* gd, time64 time)
                     tm.tm_year + 1900);
 }
 
+time64 gdate_to_time64 (GDate d)
+{
+    return gnc_dmy2time64_neutral (g_date_get_day(&d),
+                                     g_date_get_month(&d),
+                                     g_date_get_year(&d));
+}
+
 Timespec gdate_to_timespec (GDate d)
 {
     return gnc_dmy2timespec_neutral (g_date_get_day(&d),
diff --git a/libgnucash/engine/gnc-date.h b/libgnucash/engine/gnc-date.h
index 6cb5a61..97f0158 100644
--- a/libgnucash/engine/gnc-date.h
+++ b/libgnucash/engine/gnc-date.h
@@ -354,6 +354,9 @@ GDate timespec_to_gdate (Timespec ts);
 /** Turns a GDate into a Timespec, returning the first second of the day  */
 Timespec gdate_to_timespec (GDate d);
 
+/** Turns a GDate into a time64, returning the first second of the day */
+time64 gdate_to_time64 (GDate d);
+
 /** Convert a day, month, and year to a time64, returning the first second of the day */
 time64 gnc_dmy2time64 (gint day, gint month, gint year);
 
diff --git a/libgnucash/engine/gncEntry.c b/libgnucash/engine/gncEntry.c
index 07bbd62..7c351c2 100644
--- a/libgnucash/engine/gncEntry.c
+++ b/libgnucash/engine/gncEntry.c
@@ -42,8 +42,8 @@ struct _gncEntry
 {
     QofInstance inst;
 
-    Timespec	date;
-    Timespec	date_entered;
+    time64	date;
+    time64	date_entered;
     char *	desc;
     char *	action;
     char *	notes;
@@ -87,7 +87,7 @@ struct _gncEntry
     gnc_numeric	i_tax_value_rounded;
     gnc_numeric	i_disc_value;
     gnc_numeric	i_disc_value_rounded;
-    Timespec	i_taxtable_modtime;
+    time64	i_taxtable_modtime;
 
     /* vendor bill */
     gnc_numeric	b_value;
@@ -95,7 +95,7 @@ struct _gncEntry
     GList *	b_tax_values;
     gnc_numeric	b_tax_value;
     gnc_numeric	b_tax_value_rounded;
-    Timespec	b_taxtable_modtime;
+    time64	b_taxtable_modtime;
 };
 
 struct _gncEntryClass
@@ -478,14 +478,12 @@ static void gncEntryFree (GncEntry *entry)
 /* ================================================================ */
 /* Set Functions */
 
-void gncEntrySetDate (GncEntry *entry, Timespec date)
+void gncEntrySetDate (GncEntry *entry, time64 date)
 {
     gboolean first_date = FALSE;
-    Timespec zero_time = { 0, 0 };
-
     if (!entry) return;
-    if (timespec_equal (&entry->date, &date)) return;
-    if (timespec_equal (&entry->date, &zero_time))
+    if (entry->date == date) return;
+    if (!entry->date)
         first_date = TRUE;
     gncEntryBeginEdit (entry);
     entry->date = date;
@@ -510,15 +508,15 @@ void gncEntrySetDateGDate (GncEntry *entry, const GDate* date)
     /* Watch out: Here we are deviating from the initial convention that a
     GDate always converts to the start time of the day. Instead, the GDate is
     converted to "noon" on the respective date. This is not nice, but this
-    convention was used for the Timespec of GncEntry all the time, so we better
+    convention was used for the time64 of GncEntry all the time, so we better
     stick to it.*/
-    gncEntrySetDate(entry, timespecCanonicalDayTime(gdate_to_timespec(*date)));
+    gncEntrySetDate(entry, time64CanonicalDayTime(gdate_to_time64(*date)));
 }
 
-void gncEntrySetDateEntered (GncEntry *entry, Timespec date)
+void gncEntrySetDateEntered (GncEntry *entry, time64 date)
 {
     if (!entry) return;
-    if (timespec_equal (&entry->date_entered, &date)) return;
+    if (entry->date_entered == date) return;
     gncEntryBeginEdit (entry);
     entry->date_entered = date;
     mark_entry (entry);
@@ -875,37 +873,19 @@ void gncEntryCopy (const GncEntry *src, GncEntry *dest, gboolean add_entry)
 /* ================================================================ */
 /* Get Functions */
 
-Timespec gncEntryGetDate (const GncEntry *entry)
+time64 gncEntryGetDate (const GncEntry *entry)
 {
-    Timespec ts;
-    ts.tv_sec = 0;
-    ts.tv_nsec = 0;
-    if (!entry) return ts;
-    return entry->date;
-}
-
-time64 gncEntryGetDateTT (const GncEntry *entry)
-{
-    return entry ? entry->date.tv_sec : 0;
+    return entry ? entry->date : 0;
 }
 
 GDate gncEntryGetDateGDate(const GncEntry *entry)
 {
-    return timespec_to_gdate(gncEntryGetDate(entry));
-}
-
-Timespec gncEntryGetDateEntered (const GncEntry *entry)
-{
-    Timespec ts;
-    ts.tv_sec = 0;
-    ts.tv_nsec = 0;
-    if (!entry) return ts;
-    return entry->date_entered;
+    return time64_to_gdate(gncEntryGetDate(entry));
 }
 
-time64 gncEntryGetDateEnteredTT (const GncEntry *entry)
+time64 gncEntryGetDateEntered (const GncEntry *entry)
 {
-    return entry ? entry->date_entered.tv_sec : 0;
+    return entry ? entry->date_entered : 0;
 }
 
 const char * gncEntryGetDescription (const GncEntry *entry)
@@ -1353,19 +1333,19 @@ gncEntryRecomputeValues (GncEntry *entry)
     if (entry->i_tax_table)
     {
         Timespec modtime = gncTaxTableLastModified (entry->i_tax_table);
-        if (timespec_cmp (&entry->i_taxtable_modtime, &modtime))
+        if (entry->i_taxtable_modtime != modtime.tv_sec)
         {
             entry->values_dirty = TRUE;
-            entry->i_taxtable_modtime = modtime;
+            entry->i_taxtable_modtime = modtime.tv_sec;
         }
     }
     if (entry->b_tax_table)
     {
         Timespec modtime = gncTaxTableLastModified (entry->b_tax_table);
-        if (timespec_cmp (&entry->b_taxtable_modtime, &modtime))
+        if (entry->b_taxtable_modtime == modtime.tv_sec)
         {
             entry->values_dirty = TRUE;
-            entry->b_taxtable_modtime = modtime;
+            entry->b_taxtable_modtime = modtime.tv_sec;
         }
     }
 
@@ -1612,11 +1592,8 @@ int gncEntryCompare (const GncEntry *a, const GncEntry *b)
     if (!a && b) return -1;
     if (a && !b) return 1;
 
-    compare = timespec_cmp (&(a->date), &(b->date));
-    if (compare) return compare;
-
-    compare = timespec_cmp (&(a->date_entered), &(b->date_entered));
-    if (compare) return compare;
+    if (a->date != b->date) return a->date - b->date;
+    if (a->date_entered != b->date_entered) return a->date_entered - b->date_entered;
 
     compare = g_strcmp0 (a->desc, b->desc);
     if (compare) return compare;
diff --git a/libgnucash/engine/gncEntry.h b/libgnucash/engine/gncEntry.h
index b47a33d..f555d20 100644
--- a/libgnucash/engine/gncEntry.h
+++ b/libgnucash/engine/gncEntry.h
@@ -101,8 +101,8 @@ void gncEntrySetDateGDate (GncEntry *entry, const GDate* date);
 /** DEPRECATED - use gncEntrySetDateGDate() instead! (Because the time-of-day
 is a misleading extra information. We are only dealing with the day
 information! */
-void gncEntrySetDate (GncEntry *entry, Timespec date);
-void gncEntrySetDateEntered (GncEntry *entry, Timespec date);
+void gncEntrySetDate (GncEntry *entry, time64 date);
+void gncEntrySetDateEntered (GncEntry *entry, time64 date);
 void gncEntrySetDescription (GncEntry *entry, const char *desc);
 void gncEntrySetAction (GncEntry *entry, const char *action);
 void gncEntrySetNotes (GncEntry *entry, const char *notes);
@@ -159,10 +159,8 @@ GDate gncEntryGetDateGDate (const GncEntry *entry);
 /** DEPRECATED - use gncEntryGetDateGDate() instead! (Because the time-of-day
 is a misleading extra information. We are only dealing with the day
 information! */
-Timespec gncEntryGetDate (const GncEntry *entry);
-Timespec gncEntryGetDateEntered (const GncEntry *entry);
-time64 gncEntryGetDateTT (const GncEntry *entry);
-time64 gncEntryGetDateEnteredTT (const GncEntry *entry);
+time64 gncEntryGetDate (const GncEntry *entry);
+time64 gncEntryGetDateEntered (const GncEntry *entry);
 const char * gncEntryGetDescription (const GncEntry *entry);
 const char * gncEntryGetAction (const GncEntry *entry);
 const char * gncEntryGetNotes (const GncEntry *notes);
diff --git a/libgnucash/engine/test/utest-Entry.c b/libgnucash/engine/test/utest-Entry.c
index 517e09a..102b269 100644
--- a/libgnucash/engine/test/utest-Entry.c
+++ b/libgnucash/engine/test/utest-Entry.c
@@ -63,7 +63,7 @@ teardown( Fixture *fixture, gconstpointer pData )
 static void
 test_entry_basics ( Fixture *fixture, gconstpointer pData )
 {
-    Timespec ts1 = timespec_now(), ts2;
+    time64 ts1 = gnc_time(NULL), ts2;
     const char *desc = "Test description with éà unicode chars";
     const char *action = "Test action with éà unicode chars";
     const char *note = "Test note with éà unicode chars";
@@ -77,11 +77,11 @@ test_entry_basics ( Fixture *fixture, gconstpointer pData )
     g_test_message( "  Date" );
     gncEntrySetDate (entry, ts1);
     ts2 = gncEntryGetDate (entry);
-    g_assert(timespec_equal (&ts2, &ts1));
+    g_assert(ts2 == ts1);
     g_test_message( "  DateEntered" );
     gncEntrySetDateEntered (entry, ts1);
     ts2 = gncEntryGetDateEntered (entry);
-    g_assert(timespec_equal (&ts2, &ts1));
+    g_assert(ts2 == ts1);
     g_test_message( "  Description" );
     gncEntrySetDescription (entry, desc);
     g_assert(g_strcmp0 (gncEntryGetDescription (entry), desc) == 0);

commit 5dd12119b75a83cbb3f1b46c55bb81d160b32767
Author: lmat <dartme18 at gmail.com>
Date:   Fri Dec 29 14:20:24 2017 -0500

    Converted timespec_to_dom_tree to time64

diff --git a/libgnucash/backend/xml/gnc-entry-xml-v2.cpp b/libgnucash/backend/xml/gnc-entry-xml-v2.cpp
index 61f8d3b..50a1241 100644
--- a/libgnucash/backend/xml/gnc-entry-xml-v2.cpp
+++ b/libgnucash/backend/xml/gnc-entry-xml-v2.cpp
@@ -124,10 +124,10 @@ entry_dom_tree_create (GncEntry* entry)
                                         qof_instance_get_guid (QOF_INSTANCE (entry))));
 
     ts = gncEntryGetDate (entry);
-    xmlAddChild (ret, timespec_to_dom_tree (entry_date_string, &ts));
+    xmlAddChild (ret, time64_to_dom_tree (entry_date_string, ts.tv_sec));
 
     ts = gncEntryGetDateEntered (entry);
-    xmlAddChild (ret, timespec_to_dom_tree (entry_dateentered_string, &ts));
+    xmlAddChild (ret, time64_to_dom_tree (entry_dateentered_string, ts.tv_sec));
 
     maybe_add_string (ret, entry_description_string,
                       gncEntryGetDescription (entry));
diff --git a/libgnucash/backend/xml/gnc-invoice-xml-v2.cpp b/libgnucash/backend/xml/gnc-invoice-xml-v2.cpp
index fb67394..d2f2e01 100644
--- a/libgnucash/backend/xml/gnc-invoice-xml-v2.cpp
+++ b/libgnucash/backend/xml/gnc-invoice-xml-v2.cpp
@@ -83,8 +83,8 @@ maybe_add_string (xmlNodePtr ptr, const char* tag, const char* str)
 static void
 maybe_add_timespec (xmlNodePtr ptr, const char* tag, Timespec ts)
 {
-    if (ts.tv_sec || ts.tv_nsec)
-        xmlAddChild (ptr, timespec_to_dom_tree (tag, &ts));
+    if (ts.tv_sec)
+        xmlAddChild (ptr, time64_to_dom_tree (tag, ts.tv_sec));
 }
 
 static xmlNodePtr
@@ -112,7 +112,7 @@ invoice_dom_tree_create (GncInvoice* invoice)
                                              gncInvoiceGetOwner (invoice)));
 
     ts = gncInvoiceGetDateOpened (invoice);
-    xmlAddChild (ret, timespec_to_dom_tree (invoice_opened_string, &ts));
+    xmlAddChild (ret, time64_to_dom_tree (invoice_opened_string, ts.tv_sec));
 
     maybe_add_timespec (ret, invoice_posted_string,
                         gncInvoiceGetDatePosted (invoice));
diff --git a/libgnucash/backend/xml/gnc-order-xml-v2.cpp b/libgnucash/backend/xml/gnc-order-xml-v2.cpp
index fb4f1a3..1909cc5 100644
--- a/libgnucash/backend/xml/gnc-order-xml-v2.cpp
+++ b/libgnucash/backend/xml/gnc-order-xml-v2.cpp
@@ -90,11 +90,11 @@ order_dom_tree_create (GncOrder* order)
                                              gncOrderGetOwner (order)));
 
     ts = gncOrderGetDateOpened (order);
-    xmlAddChild (ret, timespec_to_dom_tree (order_opened_string, &ts));
+    xmlAddChild (ret, time64_to_dom_tree (order_opened_string, ts.tv_sec));
 
     ts = gncOrderGetDateClosed (order);
-    if (ts.tv_sec || ts.tv_nsec)
-        xmlAddChild (ret, timespec_to_dom_tree (order_closed_string, &ts));
+    if (ts.tv_sec)
+        xmlAddChild (ret, time64_to_dom_tree (order_closed_string, ts.tv_sec));
 
     maybe_add_string (ret, order_notes_string, gncOrderGetNotes (order));
     maybe_add_string (ret, order_reference_string, gncOrderGetReference (order));
diff --git a/libgnucash/backend/xml/gnc-pricedb-xml-v2.cpp b/libgnucash/backend/xml/gnc-pricedb-xml-v2.cpp
index bbb9390..6bb7dd2 100644
--- a/libgnucash/backend/xml/gnc-pricedb-xml-v2.cpp
+++ b/libgnucash/backend/xml/gnc-pricedb-xml-v2.cpp
@@ -439,7 +439,7 @@ gnc_price_to_dom_tree (const xmlChar* tag, GNCPrice* price)
     if (!add_child_or_kill_parent (price_xml, tmpnode)) return NULL;
 
     timesp = gnc_price_get_time (price);
-    tmpnode = timespec_to_dom_tree ("price:time", &timesp);
+    tmpnode = time64_to_dom_tree ("price:time", timesp.tv_sec);
     if (!add_child_or_kill_parent (price_xml, tmpnode)) return NULL;
 
     sourcestr = gnc_price_get_source_string (price);
diff --git a/libgnucash/backend/xml/gnc-transaction-xml-v2.cpp b/libgnucash/backend/xml/gnc-transaction-xml-v2.cpp
index c9ea599..06fc186 100644
--- a/libgnucash/backend/xml/gnc-transaction-xml-v2.cpp
+++ b/libgnucash/backend/xml/gnc-transaction-xml-v2.cpp
@@ -59,9 +59,9 @@ add_gnc_num (xmlNodePtr node, const gchar* tag, gnc_numeric num)
 static void
 add_timespec (xmlNodePtr node, const gchar* tag, Timespec tms, gboolean always)
 {
-    if (always || ! ((tms.tv_sec == 0) && (tms.tv_nsec == 0)))
+    if (always || tms.tv_sec)
     {
-        xmlAddChild (node, timespec_to_dom_tree (tag, &tms));
+        xmlAddChild (node, time64_to_dom_tree (tag, tms.tv_sec));
     }
 }
 
diff --git a/libgnucash/backend/xml/io-gncxml-v1.cpp b/libgnucash/backend/xml/io-gncxml-v1.cpp
index 880b532..b9153be 100644
--- a/libgnucash/backend/xml/io-gncxml-v1.cpp
+++ b/libgnucash/backend/xml/io-gncxml-v1.cpp
@@ -2350,7 +2350,7 @@ txn_rest_date_posted_end_handler (gpointer data_for_children,
                                   gpointer* result, const gchar* tag)
 {
     Transaction* t = (Transaction*) parent_data;
-    TimespecParseInfo* info = (TimespecParseInfo*) data_for_children;
+    Time64ParseInfo* info = (Time64ParseInfo*) data_for_children;
 
     g_return_val_if_fail (info, FALSE);
     if (!t || !timespec_parse_ok (info))
@@ -2359,7 +2359,7 @@ txn_rest_date_posted_end_handler (gpointer data_for_children,
         return (FALSE);
     }
 
-    xaccTransSetDatePostedTS (t, & (info->ts));
+    xaccTransSetDatePostedSecs (t, info->time);
     g_free (info);
     return (TRUE);
 }
@@ -2382,7 +2382,7 @@ txn_rest_date_entered_end_handler (gpointer data_for_children,
                                    gpointer* result, const gchar* tag)
 {
     Transaction* t = (Transaction*) parent_data;
-    TimespecParseInfo* info = (TimespecParseInfo*) data_for_children;
+    Time64ParseInfo* info = (Time64ParseInfo*) data_for_children;
 
     g_return_val_if_fail (info, FALSE);
     if (!t || !timespec_parse_ok (info))
@@ -2391,7 +2391,7 @@ txn_rest_date_entered_end_handler (gpointer data_for_children,
         return (FALSE);
     }
 
-    xaccTransSetDateEnteredTS (t, & (info->ts));
+    xaccTransSetDateEnteredSecs (t, info->time);
     g_free (info);
     return (TRUE);
 }
@@ -2713,7 +2713,7 @@ txn_restore_split_reconcile_date_end_handler (gpointer data_for_children,
                                               gpointer* result, const gchar* tag)
 {
     Split* s = (Split*) parent_data;
-    TimespecParseInfo* info = (TimespecParseInfo*) data_for_children;
+    Time64ParseInfo* info = (Time64ParseInfo*) data_for_children;
 
     g_return_val_if_fail (info, FALSE);
     if (!s || !timespec_parse_ok (info))
@@ -2722,7 +2722,7 @@ txn_restore_split_reconcile_date_end_handler (gpointer data_for_children,
         return (FALSE);
     }
 
-    xaccSplitSetDateReconciledTS (s, & (info->ts));
+    xaccSplitSetDateReconciledSecs (s, info->time);
     g_free (info);
     return (TRUE);
 }
diff --git a/libgnucash/backend/xml/sixtp-dom-generators.cpp b/libgnucash/backend/xml/sixtp-dom-generators.cpp
index 11f71cc..3f4c8de 100644
--- a/libgnucash/backend/xml/sixtp-dom-generators.cpp
+++ b/libgnucash/backend/xml/sixtp-dom-generators.cpp
@@ -137,24 +137,12 @@ time64_to_string (time64 time)
     return gnc_print_time64 (time, TIMESPEC_TIME_FORMAT " %q");
 }
 
-char*
-timespec_sec_to_string (const Timespec* ts)
-{
-    return gnc_print_time64 (ts->tv_sec, "%Y-%m-%d %H:%M:%S %q");
-}
-
-gchar*
-timespec_nsec_to_string (const Timespec* ts)
-{
-    return g_strdup_printf ("%ld", ts->tv_nsec);
-}
-
 xmlNodePtr
 time64_to_dom_tree (const char* tag, const time64 time)
 {
     xmlNodePtr ret;
     g_return_val_if_fail (time, NULL);
-    auto date_str = gnc_print_time64 (time, TIMESPEC_TIME_FORMAT " %q");
+    auto date_str = time64_to_string (time);
     if (!date_str)
         return NULL;
     ret = xmlNewNode (NULL, BAD_CAST tag);
@@ -165,46 +153,6 @@ time64_to_dom_tree (const char* tag, const time64 time)
 }
 
 xmlNodePtr
-timespec_to_dom_tree (const char* tag, const Timespec* spec)
-{
-    xmlNodePtr ret;
-    gchar* date_str = NULL;
-    gchar* ns_str = NULL;
-
-    g_return_val_if_fail (spec, NULL);
-
-    date_str = timespec_sec_to_string (spec);
-
-    if (!date_str)
-    {
-        return NULL;
-    }
-
-    ret = xmlNewNode (NULL, BAD_CAST tag);
-
-    xmlNewTextChild (ret, NULL, BAD_CAST "ts:date",
-                     checked_char_cast (date_str));
-
-    if (spec->tv_nsec > 0)
-    {
-        ns_str = timespec_nsec_to_string (spec);
-        if (ns_str)
-        {
-            xmlNewTextChild (ret, NULL, BAD_CAST "ts:ns",
-                             checked_char_cast (ns_str));
-        }
-    }
-
-    g_free (date_str);
-    if (ns_str)
-    {
-        g_free (ns_str);
-    }
-
-    return ret;
-}
-
-xmlNodePtr
 gdate_to_dom_tree (const char* tag, const GDate* date)
 {
     xmlNodePtr ret;
@@ -332,7 +280,7 @@ add_kvp_value_node (xmlNodePtr node, const gchar* tag, KvpValue* val)
     case KvpValue::Type::TIMESPEC:
     {
         auto ts = val->get<Timespec> ();
-        val_node = timespec_to_dom_tree (tag, &ts);
+        val_node = time64_to_dom_tree (tag, ts.tv_sec);
         xmlSetProp (val_node, BAD_CAST "type", BAD_CAST "timespec");
         xmlAddChild (node, val_node);
         break;
diff --git a/libgnucash/backend/xml/sixtp-dom-generators.h b/libgnucash/backend/xml/sixtp-dom-generators.h
index 33b8d4a..68a4cf0 100644
--- a/libgnucash/backend/xml/sixtp-dom-generators.h
+++ b/libgnucash/backend/xml/sixtp-dom-generators.h
@@ -40,10 +40,7 @@ xmlNodePtr int_to_dom_tree (const char* tag, gint64 val);
 xmlNodePtr boolean_to_dom_tree (const char* tag, gboolean val);
 xmlNodePtr guid_to_dom_tree (const char* tag, const GncGUID* gid);
 xmlNodePtr commodity_ref_to_dom_tree (const char* tag, const gnc_commodity* c);
-xmlNodePtr timespec_to_dom_tree (const char* tag, const Timespec* spec);
 xmlNodePtr time64_to_dom_tree (const char* tag, time64);
-gchar* timespec_nsec_to_string (const Timespec* ts);
-gchar* timespec_sec_to_string (const Timespec* ts);
 gchar* time64_to_string (time64);
 xmlNodePtr gdate_to_dom_tree (const char* tag, const GDate* spec);
 xmlNodePtr gnc_numeric_to_dom_tree (const char* tag, const gnc_numeric* num);
diff --git a/libgnucash/backend/xml/sixtp-dom-parsers.cpp b/libgnucash/backend/xml/sixtp-dom-parsers.cpp
index 82f93ee..7e4ae97 100644
--- a/libgnucash/backend/xml/sixtp-dom-parsers.cpp
+++ b/libgnucash/backend/xml/sixtp-dom-parsers.cpp
@@ -871,15 +871,3 @@ dom_tree_valid_time64 (time64 val, const xmlChar * name)
             "with a date of 1969-12-31 or 1970-01-01.", name);
     return FALSE;
 }
-
-gboolean
-dom_tree_valid_timespec (Timespec* ts, const xmlChar* name)
-{
-
-    if (ts->tv_sec || ts->tv_nsec)
-        return TRUE;
-
-    g_warning ("Invalid timestamp in data file.  Look for a '%s' entry "
-               "with a date of 1969-12-31 or 1970-01-01.", name);
-    return FALSE;
-}
diff --git a/libgnucash/backend/xml/sixtp-dom-parsers.h b/libgnucash/backend/xml/sixtp-dom-parsers.h
index 15fa1bc..c630296 100644
--- a/libgnucash/backend/xml/sixtp-dom-parsers.h
+++ b/libgnucash/backend/xml/sixtp-dom-parsers.h
@@ -43,7 +43,6 @@ GList* dom_tree_freqSpec_to_recurrences (xmlNodePtr node, QofBook* book);
 Recurrence* dom_tree_to_recurrence (xmlNodePtr node);
 
 time64 dom_tree_to_time64 (xmlNodePtr node);
-gboolean dom_tree_valid_timespec (Timespec* ts, const xmlChar* name);
 gboolean dom_tree_valid_time64 (time64 ts, const xmlChar* name);
 GDate* dom_tree_to_gdate (xmlNodePtr node);
 gnc_numeric* dom_tree_to_gnc_numeric (xmlNodePtr node);
diff --git a/libgnucash/backend/xml/sixtp-utils.cpp b/libgnucash/backend/xml/sixtp-utils.cpp
index cc242bb..5c7dfbd 100644
--- a/libgnucash/backend/xml/sixtp-utils.cpp
+++ b/libgnucash/backend/xml/sixtp-utils.cpp
@@ -356,10 +356,10 @@ simple_chars_only_parser_new (sixtp_end_handler end_handler)
        <ns>658864000</ns>
      </date-posted>
 
-   and produce a Timespec*.  The start handler for the top allocates
-   the Timespec * and passes it to the children.  The <s> block sets
-   the seconds and the <ns> block (if any) sets the nanoseconds.  If
-   all goes well, returns the Timespec* as the result.
+   and produce a time64.  The start handler for the top allocates
+   the time64 and passes it to the children.  The <s> block sets
+   the seconds and the <ns> block is ignored.  If
+   all goes well, returns the time64 as the result.
 */
 
 gboolean
@@ -372,11 +372,11 @@ string_to_time64 (const gchar* str, time64* time)
 /* Top level timespec node:
 
    input: user end handler *
-   returns: Timespec*
+   returns: time64
 
-   start: Allocates TimespecParseInfo* for data_for_children.
+   start: Allocates Time64ParseInfo* for data_for_children.
    characters: none (whitespace only).
-   end: g_free TimespecParseInfo + any other actions
+   end: g_free Time64ParseInfo + any other actions
 
    cleanup-result: NA
    cleanup-chars: NA
@@ -392,7 +392,7 @@ generic_timespec_start_handler (GSList* sibling_data, gpointer parent_data,
                                 gpointer* data_for_children, gpointer* result,
                                 const gchar* tag, gchar** attrs)
 {
-    TimespecParseInfo* tsp = g_new0 (TimespecParseInfo, 1);
+    Time64ParseInfo* tsp = g_new0 (Time64ParseInfo, 1);
     g_return_val_if_fail (tsp, FALSE);
     *data_for_children = tsp;
     return (TRUE);
@@ -403,18 +403,9 @@ generic_timespec_start_handler (GSList* sibling_data, gpointer parent_data,
    new timespec.  Otherwise, you can presume that everything's been
    cleaned up properly and return FALSE.  */
 gboolean
-timespec_parse_ok (TimespecParseInfo* info)
+timespec_parse_ok (Time64ParseInfo* info)
 {
-
-    if ((info->s_block_count > 1) || (info->ns_block_count > 1) ||
-        ((info->s_block_count == 0) && (info->ns_block_count == 0)))
-    {
-        return (FALSE);
-    }
-    else
-    {
-        return (TRUE);
-    }
+    return info->s_block_count != 1;
 }
 
 /* generic_timespec_end_handler - must be customized and provided by
@@ -422,12 +413,12 @@ timespec_parse_ok (TimespecParseInfo* info)
 
 /* <s> (parent timespec-node)
 
-   input: TimespecParseInfo *
+   input: Time64ParseInfo *
    returns: NA
 
    start: NA
    characters: accumulate.
-   end: convert characters to secs part of input Timespec and inc s_block_count.
+   end: convert characters to secs part of input time64 and inc s_block_count.
 
    cleanup-result: NA
    cleanup-chars: g_free data.
@@ -444,7 +435,7 @@ generic_timespec_secs_end_handler (gpointer data_for_children,
                                    gpointer* result, const gchar* tag)
 {
     gchar* txt = NULL;
-    TimespecParseInfo* info = (TimespecParseInfo*) parent_data;
+    Time64ParseInfo* info = (Time64ParseInfo*) parent_data;
     gboolean ok;
 
     g_return_val_if_fail (parent_data, FALSE);
@@ -452,7 +443,7 @@ generic_timespec_secs_end_handler (gpointer data_for_children,
     txt = concatenate_child_result_chars (data_from_children);
     g_return_val_if_fail (txt, FALSE);
 
-    ok = string_to_time64 (txt, & (info->ts.tv_sec));
+    ok = string_to_time64 (txt, & info->time);
     g_free (txt);
 
     g_return_val_if_fail (ok, FALSE);
@@ -463,15 +454,15 @@ generic_timespec_secs_end_handler (gpointer data_for_children,
 
 /* <s> (parent timespec-node)
 
-   input: TimespecParseInfo *
+   input: Time64ParseInfo *
    returns: NA
 
    start: NA
    characters: accumulate.
-   end: convert characters to secs part of input Timespec and inc s_block_count.
+   end: NA
 
    cleanup-result: NA
-   cleanup-chars: g_free data.
+   cleanup-chars: NA.
    fail: NA
    result-fail: NA
    chars-fail: g_free data.
diff --git a/libgnucash/backend/xml/sixtp-utils.h b/libgnucash/backend/xml/sixtp-utils.h
index 66d23e9..4129fe3 100644
--- a/libgnucash/backend/xml/sixtp-utils.h
+++ b/libgnucash/backend/xml/sixtp-utils.h
@@ -31,10 +31,9 @@ extern "C"
 
 typedef struct
 {
-    Timespec ts;
+    time64 time;
     guint s_block_count;
-    guint ns_block_count;
-} TimespecParseInfo;
+} Time64ParseInfo;
 
 #define TIMESPEC_TIME_FORMAT  "%Y-%m-%d %H:%M:%S"
 #define TIMESPEC_PARSE_TIME_FORMAT  "%Y-%m-%d %H:%M:%S"
@@ -94,7 +93,7 @@ gboolean generic_timespec_start_handler (GSList* sibling_data,
                                          gpointer* result,
                                          const gchar* tag, gchar** attrs);
 
-gboolean timespec_parse_ok (TimespecParseInfo* info);
+gboolean timespec_parse_ok (Time64ParseInfo* info);
 
 gboolean generic_timespec_secs_end_handler (
     gpointer data_for_children,

commit f77369bb963180e96945028f089de11405ad58fc
Author: lmat <dartme18 at gmail.com>
Date:   Fri Dec 29 13:52:45 2017 -0500

    Removing timspec from some xml parsing
    
    And several other sprawling references that are connected in one
    way or another.

diff --git a/libgnucash/backend/xml/gnc-entry-xml-v2.cpp b/libgnucash/backend/xml/gnc-entry-xml-v2.cpp
index 44442be..61f8d3b 100644
--- a/libgnucash/backend/xml/gnc-entry-xml-v2.cpp
+++ b/libgnucash/backend/xml/gnc-entry-xml-v2.cpp
@@ -244,9 +244,10 @@ static inline gboolean
 set_timespec (xmlNodePtr node, GncEntry* entry,
               void (*func) (GncEntry* entry, Timespec ts))
 {
-    Timespec ts = dom_tree_to_timespec (node);
-    if (!dom_tree_valid_timespec (&ts, node->name)) return FALSE;
+    time64 time = dom_tree_to_time64 (node);
+    if (!dom_tree_valid_time64 (time, node->name)) return FALSE;
 
+    Timespec ts = {time, 0};
     func (entry, ts);
     return TRUE;
 }
diff --git a/libgnucash/backend/xml/gnc-invoice-xml-v2.cpp b/libgnucash/backend/xml/gnc-invoice-xml-v2.cpp
index a5dad08..fb67394 100644
--- a/libgnucash/backend/xml/gnc-invoice-xml-v2.cpp
+++ b/libgnucash/backend/xml/gnc-invoice-xml-v2.cpp
@@ -188,9 +188,10 @@ static inline gboolean
 set_timespec (xmlNodePtr node, GncInvoice* invoice,
               void (*func) (GncInvoice* invoice, Timespec ts))
 {
-    Timespec ts = dom_tree_to_timespec (node);
-    if (!dom_tree_valid_timespec (&ts, node->name)) return FALSE;
+    time64 time = dom_tree_to_time64 (node);
+    if (!dom_tree_valid_time64 (time, node->name)) return FALSE;
 
+    Timespec ts = {time, 0};
     func (invoice, ts);
     return TRUE;
 }
diff --git a/libgnucash/backend/xml/gnc-order-xml-v2.cpp b/libgnucash/backend/xml/gnc-order-xml-v2.cpp
index b365811..fb4f1a3 100644
--- a/libgnucash/backend/xml/gnc-order-xml-v2.cpp
+++ b/libgnucash/backend/xml/gnc-order-xml-v2.cpp
@@ -134,9 +134,9 @@ static inline gboolean
 set_timespec (xmlNodePtr node, GncOrder* order,
               void (*func) (GncOrder* order, Timespec ts))
 {
-    Timespec ts = dom_tree_to_timespec (node);
-    if (!dom_tree_valid_timespec (&ts, node->name)) return FALSE;
-
+    time64 time = dom_tree_to_time64 (node);
+    if (!dom_tree_valid_time64 (time, node->name)) return FALSE;
+    Timespec ts {time, 0};
     func (order, ts);
     return TRUE;
 }
diff --git a/libgnucash/backend/xml/gnc-pricedb-xml-v2.cpp b/libgnucash/backend/xml/gnc-pricedb-xml-v2.cpp
index b25a42c..bbb9390 100644
--- a/libgnucash/backend/xml/gnc-pricedb-xml-v2.cpp
+++ b/libgnucash/backend/xml/gnc-pricedb-xml-v2.cpp
@@ -113,9 +113,10 @@ price_parse_xml_sub_node (GNCPrice* p, xmlNodePtr sub_node, QofBook* book)
     }
     else if (g_strcmp0 ("price:time", (char*)sub_node->name) == 0)
     {
-        Timespec t = dom_tree_to_timespec (sub_node);
-        if (!dom_tree_valid_timespec (&t, sub_node->name)) return FALSE;
-        gnc_price_set_time (p, t);
+        time64 time = dom_tree_to_time64 (sub_node);
+        if (!dom_tree_valid_time64 (time, sub_node->name)) return FALSE;
+        Timespec ts {time, 0};
+        gnc_price_set_time (p, ts);
     }
     else if (g_strcmp0 ("price:source", (char*)sub_node->name) == 0)
     {
diff --git a/libgnucash/backend/xml/gnc-transaction-xml-v2.cpp b/libgnucash/backend/xml/gnc-transaction-xml-v2.cpp
index c8510a3..c9ea599 100644
--- a/libgnucash/backend/xml/gnc-transaction-xml-v2.cpp
+++ b/libgnucash/backend/xml/gnc-transaction-xml-v2.cpp
@@ -275,13 +275,9 @@ static gboolean
 spl_reconcile_date_handler (xmlNodePtr node, gpointer data)
 {
     struct split_pdata* pdata = static_cast<decltype (pdata)> (data);
-    Timespec ts;
-
-    ts = dom_tree_to_timespec (node);
-    if (!dom_tree_valid_timespec (&ts, node->name)) return FALSE;
-
-    xaccSplitSetDateReconciledTS (pdata->split, &ts);
-
+    time64 time  = dom_tree_to_time64 (node);
+    if (!dom_tree_valid_time64 (time, node->name)) return FALSE;
+    xaccSplitSetDateReconciledSecs (pdata->split, time);
     return TRUE;
 }
 
@@ -434,14 +430,10 @@ static inline gboolean
 set_tran_date (xmlNodePtr node, Transaction* trn,
                void (*func) (Transaction* trn, const Timespec* tm))
 {
-    Timespec tm;
-
-    tm = dom_tree_to_timespec (node);
-
-    if (!dom_tree_valid_timespec (&tm, node->name)) return FALSE;
-
-    func (trn, &tm);
-
+    time64 time = dom_tree_to_time64 (node);
+    if (!dom_tree_valid_time64 (time, node->name)) return FALSE;
+    Timespec ts {time, 0};
+    func (trn, &ts);
     return TRUE;
 }
 
diff --git a/libgnucash/backend/xml/io-gncxml-v1.cpp b/libgnucash/backend/xml/io-gncxml-v1.cpp
index 53d6039..880b532 100644
--- a/libgnucash/backend/xml/io-gncxml-v1.cpp
+++ b/libgnucash/backend/xml/io-gncxml-v1.cpp
@@ -2959,9 +2959,10 @@ price_parse_xml_sub_node (GNCPrice* p, xmlNodePtr sub_node, QofBook* book)
     }
     else if (g_strcmp0 ("price:time", (char*)sub_node->name) == 0)
     {
-        Timespec t = dom_tree_to_timespec (sub_node);
-        if (!dom_tree_valid_timespec (&t, sub_node->name)) return FALSE;
-        gnc_price_set_time (p, t);
+        time64 time = dom_tree_to_time64 (sub_node);
+        if (!dom_tree_valid_time64 (time, sub_node->name)) return FALSE;
+        Timespec ts = {time, 0};
+        gnc_price_set_time (p, ts);
     }
     else if (g_strcmp0 ("price:source", (char*)sub_node->name) == 0)
     {
diff --git a/libgnucash/backend/xml/sixtp-dom-generators.cpp b/libgnucash/backend/xml/sixtp-dom-generators.cpp
index 25504dd..11f71cc 100644
--- a/libgnucash/backend/xml/sixtp-dom-generators.cpp
+++ b/libgnucash/backend/xml/sixtp-dom-generators.cpp
@@ -132,6 +132,12 @@ commodity_ref_to_dom_tree (const char* tag, const gnc_commodity* c)
 }
 
 char*
+time64_to_string (time64 time)
+{
+    return gnc_print_time64 (time, TIMESPEC_TIME_FORMAT " %q");
+}
+
+char*
 timespec_sec_to_string (const Timespec* ts)
 {
     return gnc_print_time64 (ts->tv_sec, "%Y-%m-%d %H:%M:%S %q");
@@ -144,6 +150,21 @@ timespec_nsec_to_string (const Timespec* ts)
 }
 
 xmlNodePtr
+time64_to_dom_tree (const char* tag, const time64 time)
+{
+    xmlNodePtr ret;
+    g_return_val_if_fail (time, NULL);
+    auto date_str = gnc_print_time64 (time, TIMESPEC_TIME_FORMAT " %q");
+    if (!date_str)
+        return NULL;
+    ret = xmlNewNode (NULL, BAD_CAST tag);
+    xmlNewTextChild (ret, NULL, BAD_CAST "ts:date",
+                     checked_char_cast (date_str));
+    g_free (date_str);
+    return ret;
+}
+
+xmlNodePtr
 timespec_to_dom_tree (const char* tag, const Timespec* spec)
 {
     xmlNodePtr ret;
diff --git a/libgnucash/backend/xml/sixtp-dom-generators.h b/libgnucash/backend/xml/sixtp-dom-generators.h
index b1b0797..33b8d4a 100644
--- a/libgnucash/backend/xml/sixtp-dom-generators.h
+++ b/libgnucash/backend/xml/sixtp-dom-generators.h
@@ -41,8 +41,10 @@ xmlNodePtr boolean_to_dom_tree (const char* tag, gboolean val);
 xmlNodePtr guid_to_dom_tree (const char* tag, const GncGUID* gid);
 xmlNodePtr commodity_ref_to_dom_tree (const char* tag, const gnc_commodity* c);
 xmlNodePtr timespec_to_dom_tree (const char* tag, const Timespec* spec);
+xmlNodePtr time64_to_dom_tree (const char* tag, time64);
 gchar* timespec_nsec_to_string (const Timespec* ts);
 gchar* timespec_sec_to_string (const Timespec* ts);
+gchar* time64_to_string (time64);
 xmlNodePtr gdate_to_dom_tree (const char* tag, const GDate* spec);
 xmlNodePtr gnc_numeric_to_dom_tree (const char* tag, const gnc_numeric* num);
 xmlNodePtr qof_instance_slots_to_dom_tree (const char* tag,
diff --git a/libgnucash/backend/xml/sixtp-dom-parsers.cpp b/libgnucash/backend/xml/sixtp-dom-parsers.cpp
index fa0dca1..82f93ee 100644
--- a/libgnucash/backend/xml/sixtp-dom-parsers.cpp
+++ b/libgnucash/backend/xml/sixtp-dom-parsers.cpp
@@ -233,14 +233,9 @@ dom_tree_to_guid_kvp_value (xmlNodePtr node)
 }
 
 static KvpValue*
-dom_tree_to_timespec_kvp_value (xmlNodePtr node)
+dom_tree_to_time64_kvp_value (xmlNodePtr node)
 {
-    Timespec ts;
-    KvpValue* ret = nullptr;
-
-    ts = dom_tree_to_timespec (node);
-    ret = new KvpValue {ts};
-    return ret;
+    return new KvpValue {Timespec {dom_tree_to_time64 (node), 0}};
 }
 
 static KvpValue*
@@ -360,7 +355,7 @@ struct kvp_val_converter val_converters[] =
     { "numeric", dom_tree_to_numeric_kvp_value },
     { "string", dom_tree_to_string_kvp_value },
     { "guid", dom_tree_to_guid_kvp_value },
-    { "timespec", dom_tree_to_timespec_kvp_value },
+    { "timespec", dom_tree_to_time64_kvp_value },
     { "gdate", dom_tree_to_gdate_kvp_value },
     { "list", dom_tree_to_list_kvp_value },
     { "frame", dom_tree_to_frame_kvp_value },
@@ -528,17 +523,15 @@ dom_tree_to_gnc_numeric (xmlNodePtr node)
     return ret;
 }
 
-static inline Timespec
-timespec_failure (Timespec ts)
+static time64
+time_parse_failure ()
 {
-    ts.tv_sec = 0;
-    ts.tv_nsec = 0;
-    return ts;
+    return 0;
 }
 
 
-Timespec
-dom_tree_to_timespec (xmlNodePtr node)
+time64
+dom_tree_to_time64 (xmlNodePtr node)
 {
     /* Turn something like this
 
@@ -547,18 +540,15 @@ dom_tree_to_timespec (xmlNodePtr node)
          <ns>658864000</ns>
        </date-posted>
 
-       into a Timespec.  If this returns FALSE, the effects on *ts are
+       into a time64.  If this returns FALSE, the effects on *ts are
        undefined.  The XML is valid if it has at least one of <s> or <ns>
        and no more than one of each.  Order is irrelevant. */
 
-    Timespec ret;
+    time64 ret {0};
     gboolean seen_s = FALSE;
     gboolean seen_ns = FALSE;
     xmlNodePtr n;
 
-
-    ret.tv_sec = 0;
-    ret.tv_nsec = 0;
     for (n = node->xmlChildrenNode; n; n = n->next)
     {
         switch (n->type)
@@ -571,52 +561,29 @@ dom_tree_to_timespec (xmlNodePtr node)
             {
                 if (seen_s)
                 {
-                    return timespec_failure (ret);
+                    return time_parse_failure ();
                 }
                 else
                 {
                     gchar* content = dom_tree_to_text (n);
                     if (!content)
                     {
-                        return timespec_failure (ret);
+                        return time_parse_failure ();
                     }
 
-                    if (!string_to_timespec_secs (content, &ret))
+                    if (!string_to_time64 (content, &ret))
                     {
                         g_free (content);
-                        return timespec_failure (ret);
+                        return time_parse_failure ();
                     }
                     g_free (content);
                     seen_s = TRUE;
                 }
             }
-            else if (g_strcmp0 ("ts:ns", (char*)n->name) == 0)
-            {
-                if (seen_ns)
-                {
-                    return timespec_failure (ret);
-                }
-                else
-                {
-                    gchar* content = dom_tree_to_text (n);
-                    if (!content)
-                    {
-                        return timespec_failure (ret);
-                    }
-
-                    if (!string_to_timespec_nsecs (content, &ret))
-                    {
-                        g_free (content);
-                        return timespec_failure (ret);
-                    }
-                    g_free (content);
-                    seen_ns = TRUE;
-                }
-            }
             break;
         default:
             PERR ("unexpected sub-node.");
-            return timespec_failure (ret);
+            return time_parse_failure ();
             break;
         }
     }
@@ -624,7 +591,7 @@ dom_tree_to_timespec (xmlNodePtr node)
     if (!seen_s)
     {
         PERR ("no ts:date node found.");
-        return timespec_failure (ret);
+        return time_parse_failure ();
     }
 
     return ret;
@@ -896,6 +863,16 @@ dom_tree_generic_parse (xmlNodePtr node, struct dom_tree_handler* handlers,
 }
 
 gboolean
+dom_tree_valid_time64 (time64 val, const xmlChar * name)
+{
+    if (val)
+        return TRUE;
+    g_warning ("Invalid timestamp in data file. Look for a '%s' entry "
+            "with a date of 1969-12-31 or 1970-01-01.", name);
+    return FALSE;
+}
+
+gboolean
 dom_tree_valid_timespec (Timespec* ts, const xmlChar* name)
 {
 
diff --git a/libgnucash/backend/xml/sixtp-dom-parsers.h b/libgnucash/backend/xml/sixtp-dom-parsers.h
index 7890bd9..15fa1bc 100644
--- a/libgnucash/backend/xml/sixtp-dom-parsers.h
+++ b/libgnucash/backend/xml/sixtp-dom-parsers.h
@@ -42,8 +42,9 @@ gnc_commodity* dom_tree_to_commodity_ref_no_engine (xmlNodePtr node, QofBook*);
 GList* dom_tree_freqSpec_to_recurrences (xmlNodePtr node, QofBook* book);
 Recurrence* dom_tree_to_recurrence (xmlNodePtr node);
 
-Timespec dom_tree_to_timespec (xmlNodePtr node);
+time64 dom_tree_to_time64 (xmlNodePtr node);
 gboolean dom_tree_valid_timespec (Timespec* ts, const xmlChar* name);
+gboolean dom_tree_valid_time64 (time64 ts, const xmlChar* name);
 GDate* dom_tree_to_gdate (xmlNodePtr node);
 gnc_numeric* dom_tree_to_gnc_numeric (xmlNodePtr node);
 gchar* dom_tree_to_text (xmlNodePtr tree);
diff --git a/libgnucash/backend/xml/sixtp-utils.cpp b/libgnucash/backend/xml/sixtp-utils.cpp
index 8c3cb1d..cc242bb 100644
--- a/libgnucash/backend/xml/sixtp-utils.cpp
+++ b/libgnucash/backend/xml/sixtp-utils.cpp
@@ -363,16 +363,9 @@ simple_chars_only_parser_new (sixtp_end_handler end_handler)
 */
 
 gboolean
-string_to_timespec_secs (const gchar* str, Timespec* ts)
+string_to_time64 (const gchar* str, time64* time)
 {
-    *ts = gnc_iso8601_to_timespec_gmt (str);
-    return (TRUE);
-}
-
-gboolean
-string_to_timespec_nsecs (const gchar* str, Timespec* ts)
-{
-    /* We don't do nanoseconds anymore. */
+    *time = gnc_iso8601_to_time64_gmt (str);
     return (TRUE);
 }
 
@@ -459,7 +452,7 @@ generic_timespec_secs_end_handler (gpointer data_for_children,
     txt = concatenate_child_result_chars (data_from_children);
     g_return_val_if_fail (txt, FALSE);
 
-    ok = string_to_timespec_secs (txt, & (info->ts));
+    ok = string_to_time64 (txt, & (info->ts.tv_sec));
     g_free (txt);
 
     g_return_val_if_fail (ok, FALSE);
@@ -491,22 +484,7 @@ generic_timespec_nsecs_end_handler (gpointer data_for_children,
                                     gpointer parent_data, gpointer global_data,
                                     gpointer* result, const gchar* tag)
 {
-    gchar* txt = NULL;
-    TimespecParseInfo* info = (TimespecParseInfo*) parent_data;
-    gboolean ok;
-
-    g_return_val_if_fail (parent_data, FALSE);
-
-    txt = concatenate_child_result_chars (data_from_children);
-    g_return_val_if_fail (txt, FALSE);
-
-    ok = string_to_timespec_nsecs (txt, & (info->ts));
-    g_free (txt);
-
-    g_return_val_if_fail (ok, FALSE);
-
-    info->ns_block_count++;
-    return (TRUE);
+    return TRUE;
 }
 
 static sixtp*
diff --git a/libgnucash/backend/xml/sixtp-utils.h b/libgnucash/backend/xml/sixtp-utils.h
index cf3f3c9..66d23e9 100644
--- a/libgnucash/backend/xml/sixtp-utils.h
+++ b/libgnucash/backend/xml/sixtp-utils.h
@@ -85,8 +85,7 @@ gboolean generic_return_chars_end_handler (gpointer data_for_children,
 
 sixtp* simple_chars_only_parser_new (sixtp_end_handler end_handler);
 
-gboolean string_to_timespec_secs (const gchar* str, Timespec* ts);
-gboolean string_to_timespec_nsecs (const gchar* str, Timespec* ts);
+gboolean string_to_time64 (const gchar* str, time64* ts);
 
 gboolean generic_timespec_start_handler (GSList* sibling_data,
                                          gpointer parent_data,
diff --git a/libgnucash/backend/xml/test/test-date-converting.cpp b/libgnucash/backend/xml/test/test-date-converting.cpp
index cae7c19..d940d81 100644
--- a/libgnucash/backend/xml/test/test-date-converting.cpp
+++ b/libgnucash/backend/xml/test/test-date-converting.cpp
@@ -41,51 +41,26 @@ main (int argc, char** argv)
 
     for (i = 0; i < 20; i++)
     {
-        Timespec* spec1;
-        Timespec spec2;
-        gchar* sec_str;
-        gchar* nsec_str;
-
-        spec1 = get_random_timespec ();
-
-        sec_str = timespec_sec_to_string (spec1);
-        nsec_str = timespec_nsec_to_string (spec1);
-
-        if (!string_to_timespec_secs (sec_str, &spec2))
+        time64 spec2;
+        auto spec1 = get_random_time ();
+        auto sec_str = time64_to_string (spec1);
+        if (!string_to_time64 (sec_str, &spec2))
         {
             failure_args ("string_to_timespec_secs", __FILE__, __LINE__,
                           "string is %s", sec_str);
         }
-
-        else if (!string_to_timespec_nsecs (nsec_str, &spec2))
-        {
-            failure_args ("string_to_timespec_nsecs", __FILE__, __LINE__,
-                          "string is %s", nsec_str);
-        }
-
-        else if (spec1->tv_sec != spec2.tv_sec)
+        else if (spec1 != spec2)
         {
             failure_args ("timespec_secs", __FILE__, __LINE__,
                           "not equal ints are %" G_GINT64_FORMAT
                           " and %" G_GINT64_FORMAT "\n",
-                          spec1->tv_sec, spec2.tv_sec);
-        }
-
-        else if (spec1->tv_nsec != spec2.tv_nsec)
-        {
-            failure_args ("timespec_nsecs", __FILE__, __LINE__,
-                          "not equal ints are %ld and %ld\n",
-                          spec1->tv_nsec, spec2.tv_nsec);
+                          spec1, spec2);
         }
-
         else
         {
             success ("timespec");
         }
-
-        g_free (spec1);
         g_free (sec_str);
-        g_free (nsec_str);
     }
     print_test_results ();
     exit (get_rv ());
diff --git a/libgnucash/backend/xml/test/test-dom-converters1.cpp b/libgnucash/backend/xml/test/test-dom-converters1.cpp
index 1035c6e..a6124d8 100644
--- a/libgnucash/backend/xml/test/test-dom-converters1.cpp
+++ b/libgnucash/backend/xml/test/test-dom-converters1.cpp
@@ -132,17 +132,11 @@ test_dom_tree_to_timespec (void)
     int i;
     for (i = 0; i < 20; i++)
     {
-        Timespec* test_spec1;
-        Timespec test_spec2;
         xmlNodePtr test_node;
-
-        test_spec1 = get_random_timespec ();
-
-        test_node = timespec_to_dom_tree ("test-spec", test_spec1);
-
-        test_spec2 = dom_tree_to_timespec (test_node);
-
-        if (!dom_tree_valid_timespec (&test_spec2, (const xmlChar*)"test-spec"))
+        time64 test_spec1 = get_random_time ();
+        test_node = time64_to_dom_tree ("test-spec", test_spec1);
+        time64 test_spec2 = dom_tree_to_time64 (test_node);
+        if (!dom_tree_valid_time64 (test_spec2, (const xmlChar*)"test-spec"))
         {
             failure_args ("dom_tree_to_timespec",
                           __FILE__, __LINE__, "NULL return");
@@ -150,8 +144,7 @@ test_dom_tree_to_timespec (void)
             xmlElemDump (stdout, NULL, test_node);
             printf ("\n");
         }
-
-        else if (timespec_cmp (test_spec1, &test_spec2) == 0)
+        else if (test_spec1 == test_spec2)
         {
             success ("dom_tree_to_timespec");
         }
@@ -161,15 +154,9 @@ test_dom_tree_to_timespec (void)
             printf ("Node looks like:\n");
             xmlElemDump (stdout, NULL, test_node);
             printf ("\n");
-            printf ("Secs are %" G_GUINT64_FORMAT " vs %" G_GUINT64_FORMAT " :: ",
-                    test_spec1->tv_sec,
-                    test_spec2.tv_sec);
-            printf ("NSecs are %ld vs %ld\n",
-                    test_spec1->tv_nsec,
-                    test_spec2.tv_nsec);
+            printf ("passed: %" G_GUINT64_FORMAT "  got: %" G_GUINT64_FORMAT ".\n",
+                    test_spec1, test_spec2);
         }
-
-        g_free (test_spec1);
         xmlFreeNode (test_node);
     }
 }
diff --git a/libgnucash/backend/xml/test/test-file-stuff.cpp b/libgnucash/backend/xml/test/test-file-stuff.cpp
index 3962a82..d378d52 100644
--- a/libgnucash/backend/xml/test/test-file-stuff.cpp
+++ b/libgnucash/backend/xml/test/test-file-stuff.cpp
@@ -279,16 +279,8 @@ equals_node_val_vs_kvp_frame (xmlNodePtr node, const KvpFrame* frm)
 gboolean
 equals_node_val_vs_date (xmlNodePtr node, const Timespec tm)
 {
-    Timespec tm_test = dom_tree_to_timespec (node);
-
-    if (tm_test.tv_sec == tm.tv_sec && tm_test.tv_nsec == tm.tv_nsec)
-    {
-        return TRUE;
-    }
-    else
-    {
-        return FALSE;
-    }
+    time64 time = dom_tree_to_time64 (node);
+    return time == tm.tv_sec;
 }
 
 /***********************************************************************/
diff --git a/libgnucash/engine/Transaction.c b/libgnucash/engine/Transaction.c
index 2ff4af4..dfc9107 100644
--- a/libgnucash/engine/Transaction.c
+++ b/libgnucash/engine/Transaction.c
@@ -2766,7 +2766,7 @@ xaccTransGetVoidTime(const Transaction *tr)
     if (G_VALUE_HOLDS_STRING (&v))
         s = g_value_get_string (&v);
     if (s)
-        return gnc_iso8601_to_timespec_gmt (s).tv_sec;
+        return gnc_iso8601_to_time64_gmt (s);
     return void_time;
 }
 
diff --git a/libgnucash/engine/gnc-date.cpp b/libgnucash/engine/gnc-date.cpp
index 4d361e8..b46024c 100644
--- a/libgnucash/engine/gnc-date.cpp
+++ b/libgnucash/engine/gnc-date.cpp
@@ -1198,25 +1198,25 @@ gnc_date_timestamp (void)
  */
 
 #define ISO_DATE_FORMAT "%d-%d-%d %d:%d:%lf%s"
-Timespec
-gnc_iso8601_to_timespec_gmt(const char *cstr)
+time64
+gnc_iso8601_to_time64_gmt(const char *cstr)
 {
     time64 time;
-    if (!cstr) return {0, 0};
+    if (!cstr) return 0;
     try
     {
         GncDateTime gncdt(cstr);
-        return {static_cast<time64>(gncdt), 0};
+        return static_cast<time64>(gncdt);
     }
     catch(std::logic_error& err)
     {
         PWARN("Error processing %s: %s", cstr, err.what());
-        return {0, 0};
+        return 0;
     }
     catch(std::runtime_error& err)
     {
         PWARN("Error processing time64 %s: %s", cstr, err.what());
-        return {0, 0};
+        return 0;
     }
 }
 
diff --git a/libgnucash/engine/gnc-date.h b/libgnucash/engine/gnc-date.h
index f948549..6cb5a61 100644
--- a/libgnucash/engine/gnc-date.h
+++ b/libgnucash/engine/gnc-date.h
@@ -392,7 +392,7 @@ Timespec gnc_dmy2timespec_neutral (gint day, gint month, gint year);
  * XXX Caution: this routine does not handle strings that specify
  * times before January 1 1970.
  */
-Timespec gnc_iso8601_to_timespec_gmt(const gchar *);
+time64 gnc_iso8601_to_time64_gmt(const gchar *);
 
 /** The gnc_timespec_to_iso8601_buff() routine takes the input
  *    UTC Timespec value and prints it as an ISO-8601 style string.
diff --git a/libgnucash/engine/test-core/test-engine-stuff.cpp b/libgnucash/engine/test-core/test-engine-stuff.cpp
index ab2cb02..c7bca6a 100644
--- a/libgnucash/engine/test-core/test-engine-stuff.cpp
+++ b/libgnucash/engine/test-core/test-engine-stuff.cpp
@@ -227,6 +227,15 @@ get_random_glist_depth (gint depth)
 /* ========================================================== */
 /* Time/Date, GncGUID data stuff */
 
+time64
+get_random_time (void)
+{
+    time64 ret {0};
+    while (ret <= 0)
+        ret = rand();
+    return ret;
+}
+
 Timespec*
 get_random_timespec(void)
 {
diff --git a/libgnucash/engine/test-core/test-engine-stuff.h b/libgnucash/engine/test-core/test-engine-stuff.h
index e80b60e..5f8d69d 100644
--- a/libgnucash/engine/test-core/test-engine-stuff.h
+++ b/libgnucash/engine/test-core/test-engine-stuff.h
@@ -46,6 +46,7 @@ typedef struct KvpFrameImpl KvpFrame;
 #define __KVP_FRAME
 #endif
 Timespec* get_random_timespec(void);
+time64 get_random_time(void);
 void random_timespec_zero_nsec (gboolean zero_nsec);
 void random_timespec_usec_resolution (gboolean usec_resolution);
 
diff --git a/libgnucash/engine/test/test-date.cpp b/libgnucash/engine/test/test-date.cpp
index fe7b1e5..9014fcd 100644
--- a/libgnucash/engine/test/test-date.cpp
+++ b/libgnucash/engine/test/test-date.cpp
@@ -52,7 +52,7 @@ check_time (Timespec ts, gboolean always_print)
      * the time, in seconds, is identical to the local time in
      * Greenwich (GMT).
      */
-    ts_2 = gnc_iso8601_to_timespec_gmt (str);
+    ts_2 = {gnc_iso8601_to_time64_gmt (str), 0};
 
     ok = timespec_equal (&ts, &ts_2);
 
@@ -85,7 +85,7 @@ check_conversion (const char * str, Timespec expected_ts)
     int day, month, year;
     GDate d1, d2;
 
-    ts = gnc_iso8601_to_timespec_gmt (str);
+    ts = {gnc_iso8601_to_time64_gmt (str), 0};
 
     // We test the conversion to GDate against the timespec2dmy
     // conversion, and also the conversion back to timespec and again
@@ -309,31 +309,31 @@ run_test (void)
 
 
     /* Various leap-year days and near-leap times. */
-    ts = gnc_iso8601_to_timespec_gmt ("1980-02-29 00:00:00.000000 -0000");
+    ts = {gnc_iso8601_to_time64_gmt ("1980-02-29 00:00:00.000000 -0000"), 0};
     check_time (ts, do_print);
 
-    ts = gnc_iso8601_to_timespec_gmt ("1979-02-28 00:00:00.000000 -0000");
+    ts = {gnc_iso8601_to_time64_gmt ("1979-02-28 00:00:00.000000 -0000"), 0};
     check_time (ts, do_print);
 
-    ts = gnc_iso8601_to_timespec_gmt ("1990-02-28 00:00:00.000000 -0000");
+    ts = {gnc_iso8601_to_time64_gmt ("1990-02-28 00:00:00.000000 -0000"), 0};
     check_time (ts, do_print);
 
-    ts = gnc_iso8601_to_timespec_gmt ("2000-02-29 00:00:00.000000 -0000");
+    ts = {gnc_iso8601_to_time64_gmt ("2000-02-29 00:00:00.000000 -0000"), 0};
     check_time (ts, do_print);
 
-    ts = gnc_iso8601_to_timespec_gmt ("2004-02-29 00:00:00.000000 -0000");
+    ts = {gnc_iso8601_to_time64_gmt ("2004-02-29 00:00:00.000000 -0000"), 0};
     check_time (ts, do_print);
 
-    ts = gnc_iso8601_to_timespec_gmt ("2008-02-29 00:00:00.000000 -0000");
+    ts = {gnc_iso8601_to_time64_gmt ("2008-02-29 00:00:00.000000 -0000"), 0};
     check_time (ts, do_print);
 
-    ts = gnc_iso8601_to_timespec_gmt ("2008-02-29 00:01:00.000000 -0000");
+    ts = {gnc_iso8601_to_time64_gmt ("2008-02-29 00:01:00.000000 -0000"), 0};
     check_time (ts, do_print);
 
-    ts = gnc_iso8601_to_timespec_gmt ("2008-02-29 02:02:00.000000 -0000");
+    ts = {gnc_iso8601_to_time64_gmt ("2008-02-29 02:02:00.000000 -0000"), 0};
     check_time (ts, do_print);
 
-    ts = gnc_iso8601_to_timespec_gmt ("2008-02-28 23:23:23.000000 -0000");
+    ts = {gnc_iso8601_to_time64_gmt ("2008-02-28 23:23:23.000000 -0000"), 0};
     check_time (ts, do_print);
 
     /* Here's a date ten days after the 2038 rollover that should work
diff --git a/libgnucash/engine/test/test-gnc-date.c b/libgnucash/engine/test/test-gnc-date.c
index 5e23396..a86bfb3 100644
--- a/libgnucash/engine/test/test-gnc-date.c
+++ b/libgnucash/engine/test/test-gnc-date.c
@@ -1635,17 +1635,15 @@ get_nanoseconds (GDateTime *gdt)
 static void
 test_gnc_iso8601_to_timespec_gmt (FixtureA *f, gconstpointer pData)
 {
-    Timespec t;
-
-    t = gnc_iso8601_to_timespec_gmt (NULL);
+    Timespec t = {gnc_iso8601_to_time64_gmt (NULL), 0};
     g_assert_cmpint (t.tv_sec, ==, 0);
     g_assert_cmpint (t.tv_nsec, ==, 0);
 
-    t = gnc_iso8601_to_timespec_gmt ("");
+    t.tv_sec = gnc_iso8601_to_time64_gmt ("");
     g_assert_cmpint (t.tv_sec, ==, 0);
     g_assert_cmpint (t.tv_nsec, ==, 0);
 
-    t = gnc_iso8601_to_timespec_gmt ("1989-03-27 13:43:27");
+    t.tv_sec = gnc_iso8601_to_time64_gmt ("1989-03-27 13:43:27");
     g_assert_cmpint (t.tv_sec, ==, f->ts1.tv_sec);
     /* MinGW has some precision issues in the last microsecond digit */
 #ifdef G_OS_WIN32
@@ -1654,19 +1652,19 @@ test_gnc_iso8601_to_timespec_gmt (FixtureA *f, gconstpointer pData)
 #else
     g_assert_cmpint (t.tv_nsec, ==, f->ts1.tv_nsec);
 #endif
-    t = gnc_iso8601_to_timespec_gmt ("2020-11-07 06:21:19 -05");
+    t.tv_sec = gnc_iso8601_to_time64_gmt ("2020-11-07 06:21:19 -05");
     g_assert_cmpint (t.tv_sec, ==, f->ts2.tv_sec);
     g_assert_cmpint (t.tv_nsec, ==, f->ts2.tv_nsec);
 
-    t = gnc_iso8601_to_timespec_gmt ("2012-07-04 19:27:44.0+08:40");
+    t.tv_sec = gnc_iso8601_to_time64_gmt ("2012-07-04 19:27:44.0+08:40");
     g_assert_cmpint (t.tv_sec, ==, f->ts3.tv_sec);
     g_assert_cmpint (t.tv_nsec, ==, f->ts3.tv_nsec);
 
-    t = gnc_iso8601_to_timespec_gmt ("1961-09-22 17:53:19 -05");
+    t.tv_sec = gnc_iso8601_to_time64_gmt ("1961-09-22 17:53:19 -05");
     g_assert_cmpint (t.tv_sec, ==, f->ts4.tv_sec);
     g_assert_cmpint (t.tv_nsec, ==, f->ts4.tv_nsec);
 
-    t = gnc_iso8601_to_timespec_gmt ("2061-01-25 23:21:19.0 -05:00");
+    t.tv_sec = gnc_iso8601_to_time64_gmt ("2061-01-25 23:21:19.0 -05:00");
     g_assert_cmpint (t.tv_sec, ==, f->ts5.tv_sec);
     g_assert_cmpint (t.tv_nsec, ==, f->ts5.tv_nsec);
 }

commit 7390396af907be3eb87aaaee4c48af37bb6932b2
Author: lmat <dartme18 at gmail.com>
Date:   Sat Dec 23 13:18:23 2017 -0500

    added gnc-dmy2time64* functions

diff --git a/libgnucash/engine/gnc-date.cpp b/libgnucash/engine/gnc-date.cpp
index 060625f..4d361e8 100644
--- a/libgnucash/engine/gnc-date.cpp
+++ b/libgnucash/engine/gnc-date.cpp
@@ -1287,6 +1287,24 @@ gnc_dmy2timespec_internal (int day, int month, int year, DayPart day_part)
     }
 }
 
+time64
+gnc_dmy2time64 (int day, int month, int year)
+{
+    return gnc_dmy2timespec_internal (day, month, year, DayPart::start).tv_sec;
+}
+
+time64
+gnc_dmy2time64_end (int day, int month, int year)
+{
+    return gnc_dmy2timespec_internal (day, month, year, DayPart::end).tv_sec;
+}
+
+time64
+gnc_dmy2time64_neutral (int day, int month, int year)
+{
+    return gnc_dmy2timespec_internal (day, month, year, DayPart::neutral).tv_sec;
+}
+
 Timespec
 gnc_dmy2timespec (int day, int month, int year)
 {
diff --git a/libgnucash/engine/gnc-date.h b/libgnucash/engine/gnc-date.h
index 113e4a0..f948549 100644
--- a/libgnucash/engine/gnc-date.h
+++ b/libgnucash/engine/gnc-date.h
@@ -354,6 +354,13 @@ GDate timespec_to_gdate (Timespec ts);
 /** Turns a GDate into a Timespec, returning the first second of the day  */
 Timespec gdate_to_timespec (GDate d);
 
+/** Convert a day, month, and year to a time64, returning the first second of the day */
+time64 gnc_dmy2time64 (gint day, gint month, gint year);
+
+time64 gnc_dmy2time64_neutral (gint day, gint month, gint year);
+
+time64 gnc_dmy2time64_end (gint day, gint month, gint year);
+
 /** Convert a day, month, and year to a Timespec, returning the first second of the day */
 Timespec gnc_dmy2timespec (gint day, gint month, gint year);
 

commit 3067486352d83ca95bcb9ac35663b826f0815cdd
Author: lmat <dartme18 at gmail.com>
Date:   Sat Dec 23 13:07:30 2017 -0500

    gnc_option_get_ui_value_date uses time64

diff --git a/gnucash/gnome-utils/dialog-options.c b/gnucash/gnome-utils/dialog-options.c
index 3504c77..208a27a 100644
--- a/gnucash/gnome-utils/dialog-options.c
+++ b/gnucash/gnome-utils/dialog-options.c
@@ -3791,16 +3791,13 @@ gnc_option_get_ui_value_date (GNCOption *option, GtkWidget *widget)
     }
     else if (g_strcmp0(subtype, "absolute") == 0)
     {
-        Timespec ts;
-
-        ts.tv_sec  = gnc_date_edit_get_date(GNC_DATE_EDIT(widget));
-        ts.tv_nsec = 0;
-
-        result = scm_cons(scm_from_locale_symbol ("absolute"), gnc_timespec2timepair(ts));
+        time64 time;
+        time = gnc_date_edit_get_date(GNC_DATE_EDIT(widget));
+        result = scm_cons(scm_from_locale_symbol ("absolute"), scm_from_int64(time));
     }
     else if (g_strcmp0(subtype, "both") == 0)
     {
-        Timespec ts;
+        time64 time;
         int index;
         SCM val;
         GList *widget_list;
@@ -3815,9 +3812,8 @@ gnc_option_get_ui_value_date (GNCOption *option, GtkWidget *widget)
         /* if it's an absolute date */
         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ab_button)))
         {
-            ts.tv_sec = gnc_date_edit_get_date(GNC_DATE_EDIT(ab_widget));
-            ts.tv_nsec = 0;
-            result = scm_cons(scm_from_locale_symbol ("absolute"), gnc_timespec2timepair(ts));
+            time = gnc_date_edit_get_date(GNC_DATE_EDIT(ab_widget));
+            result = scm_cons(scm_from_locale_symbol ("absolute"), scm_from_int64 (time));
         }
         else
         {

commit 588fcb6ed2785431640b0d0563368e29bf70886c
Author: lmat <dartme18 at gmail.com>
Date:   Sat Dec 23 13:06:59 2017 -0500

    Transaction getVoidTime uses time64.

diff --git a/libgnucash/engine/Transaction.c b/libgnucash/engine/Transaction.c
index 8f434f9..2ff4af4 100644
--- a/libgnucash/engine/Transaction.c
+++ b/libgnucash/engine/Transaction.c
@@ -2754,19 +2754,19 @@ xaccTransGetVoidReason(const Transaction *trans)
     return NULL;
 }
 
-Timespec
+time64
 xaccTransGetVoidTime(const Transaction *tr)
 {
     GValue v = G_VALUE_INIT;
     const char *s = NULL;
-    Timespec void_time = {0, 0};
+    time64 void_time = 0;
 
     g_return_val_if_fail(tr, void_time);
     qof_instance_get_kvp (QOF_INSTANCE (tr), &v, 1, void_time_str);
     if (G_VALUE_HOLDS_STRING (&v))
         s = g_value_get_string (&v);
     if (s)
-        return gnc_iso8601_to_timespec_gmt (s);
+        return gnc_iso8601_to_timespec_gmt (s).tv_sec;
     return void_time;
 }
 
diff --git a/libgnucash/engine/Transaction.h b/libgnucash/engine/Transaction.h
index 6c26c0f..6104633 100644
--- a/libgnucash/engine/Transaction.h
+++ b/libgnucash/engine/Transaction.h
@@ -756,10 +756,10 @@ const char *xaccTransGetVoidReason(const Transaction *transaction);
  *
  *  @param tr The transaction in question.
  *
- *  @return A Timespec containing the time that this transaction was
+ *  @return A time64 containing the time that this transaction was
  *  voided. Returns a time of zero upon error.
  */
-Timespec xaccTransGetVoidTime(const Transaction *tr);
+time64 xaccTransGetVoidTime(const Transaction *tr);
 /** @} */
 
 /** @name Transaction Parameter names
diff --git a/libgnucash/engine/test/test-transaction-voiding.cpp b/libgnucash/engine/test/test-transaction-voiding.cpp
index 2e59d74..fcc86e1 100644
--- a/libgnucash/engine/test/test-transaction-voiding.cpp
+++ b/libgnucash/engine/test/test-transaction-voiding.cpp
@@ -58,7 +58,7 @@ run_test (void)
     Transaction *transaction;
     gnc_numeric old_amt, new_amt, old_val, new_val;
     QofBook *book;
-    Timespec ts;
+    time64 time;
     time64 now;
 
     const char *reason = "because I can";
@@ -97,10 +97,10 @@ run_test (void)
 
     xaccTransVoid(transaction, reason);
 
-    ts = xaccTransGetVoidTime (transaction);
+    time = xaccTransGetVoidTime (transaction);
 
     /* figure at most 2 seconds difference */
-    if ((ts.tv_sec < now) || ((ts.tv_sec - now) > 2))
+    if ((time < now) || ((time - now) > 2))
     {
         failure("bad void time");
     }
@@ -146,10 +146,10 @@ run_test (void)
      */
     xaccTransUnvoid(transaction);
 
-    ts = xaccTransGetVoidTime (transaction);
+    time = xaccTransGetVoidTime (transaction);
 
     /* figure at most 2 seconds difference */
-    if ((ts.tv_sec != 0) || (ts.tv_sec != 0))
+    if ((time != 0))
     {
         failure("void time not zero after restore");
     }
@@ -193,7 +193,7 @@ run_test (void)
     xaccTransSetReadOnly (transaction, "Read-only void test");
     xaccTransVoid(transaction, reason);
 
-    ts = xaccTransGetVoidTime (transaction);
+    time = xaccTransGetVoidTime (transaction);
 
     if (xaccTransGetVoidStatus(transaction))
     {

commit 978ec61f98f8620de43dbe701b9a7914c8f6eece
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Nov 22 18:43:13 2017 +0800

    Further scheme conversion to gdate to use time64
    
    Add missing time64_to_gdate

diff --git a/libgnucash/engine/gnc-date.cpp b/libgnucash/engine/gnc-date.cpp
index 86e56b7..060625f 100644
--- a/libgnucash/engine/gnc-date.cpp
+++ b/libgnucash/engine/gnc-date.cpp
@@ -1346,6 +1346,20 @@ GDate timespec_to_gdate (Timespec ts)
     return result;
 }
 
+GDate time64_to_gdate (time64 t)
+{
+    GDate result;
+
+    g_date_clear (&result, 1);
+    GncDateTime time(t);
+    auto date = time.date().year_month_day();
+    g_date_set_dmy (&result, date.day, static_cast<GDateMonth>(date.month),
+                    date.year);
+    g_assert(g_date_valid (&result));
+
+    return result;
+}
+
 GDate* gnc_g_date_new_today ()
 {
     GncDate gncd;

commit 0bf0989aa77dbf2f7e66c65ac5c7a5bb4776d9c9
Author: lmat <dartme18 at gmail.com>
Date:   Mon Dec 18 06:51:33 2017 -0800

    Add time64 functions for gncEntry

diff --git a/libgnucash/engine/gncEntry.c b/libgnucash/engine/gncEntry.c
index 151526f..07bbd62 100644
--- a/libgnucash/engine/gncEntry.c
+++ b/libgnucash/engine/gncEntry.c
@@ -884,6 +884,11 @@ Timespec gncEntryGetDate (const GncEntry *entry)
     return entry->date;
 }
 
+time64 gncEntryGetDateTT (const GncEntry *entry)
+{
+    return entry ? entry->date.tv_sec : 0;
+}
+
 GDate gncEntryGetDateGDate(const GncEntry *entry)
 {
     return timespec_to_gdate(gncEntryGetDate(entry));
@@ -898,6 +903,11 @@ Timespec gncEntryGetDateEntered (const GncEntry *entry)
     return entry->date_entered;
 }
 
+time64 gncEntryGetDateEnteredTT (const GncEntry *entry)
+{
+    return entry ? entry->date_entered.tv_sec : 0;
+}
+
 const char * gncEntryGetDescription (const GncEntry *entry)
 {
     if (!entry) return NULL;
diff --git a/libgnucash/engine/gncEntry.h b/libgnucash/engine/gncEntry.h
index 8440396..b47a33d 100644
--- a/libgnucash/engine/gncEntry.h
+++ b/libgnucash/engine/gncEntry.h
@@ -161,6 +161,8 @@ is a misleading extra information. We are only dealing with the day
 information! */
 Timespec gncEntryGetDate (const GncEntry *entry);
 Timespec gncEntryGetDateEntered (const GncEntry *entry);
+time64 gncEntryGetDateTT (const GncEntry *entry);
+time64 gncEntryGetDateEnteredTT (const GncEntry *entry);
 const char * gncEntryGetDescription (const GncEntry *entry);
 const char * gncEntryGetAction (const GncEntry *entry);
 const char * gncEntryGetNotes (const GncEntry *notes);

commit dbd1473730303c113afc6f252e1b3a867d490269
Author: lmat <dartme18 at gmail.com>
Date:   Sun Dec 17 05:05:21 2017 -0800

    Adding time64 alternatives

diff --git a/libgnucash/engine/gncInvoice.c b/libgnucash/engine/gncInvoice.c
index ac8eaac..670c344 100644
--- a/libgnucash/engine/gncInvoice.c
+++ b/libgnucash/engine/gncInvoice.c
@@ -835,6 +835,24 @@ Timespec gncInvoiceGetDateDue (const GncInvoice *invoice)
     return xaccTransRetDateDueTS (txn);
 }
 
+time64 gncInvoiceGetDateOpenedTT (const GncInvoice *invoice)
+{
+    if (!invoice) return 0;
+    return invoice->date_opened.tv_sec;
+}
+
+time64 gncInvoiceGetDatePostedTT (const GncInvoice *invoice)
+{
+    if (!invoice) return 0;
+    return invoice->date_posted.tv_sec;
+}
+
+time64 gncInvoiceGetDateDueTT (const GncInvoice *invoice)
+{
+    if (!invoice) return 0;
+    return gncInvoiceGetDateDue (invoice).tv_sec;
+}
+
 GncBillTerm * gncInvoiceGetTerms (const GncInvoice *invoice)
 {
     if (!invoice) return NULL;
diff --git a/libgnucash/engine/gncInvoice.h b/libgnucash/engine/gncInvoice.h
index 4914432..6585898 100644
--- a/libgnucash/engine/gncInvoice.h
+++ b/libgnucash/engine/gncInvoice.h
@@ -138,8 +138,11 @@ void gncInvoiceRemoveEntries (GncInvoice *invoice);
 const char * gncInvoiceGetID (const GncInvoice *invoice);
 const GncOwner * gncInvoiceGetOwner (const GncInvoice *invoice);
 Timespec gncInvoiceGetDateOpened (const GncInvoice *invoice);
+time64 gncInvoiceGetDateOpenedTT (const GncInvoice *invoice);
 Timespec gncInvoiceGetDatePosted (const GncInvoice *invoice);
+time64 gncInvoiceGetDatePostedTT (const GncInvoice *invoice);
 Timespec gncInvoiceGetDateDue (const GncInvoice *invoice);
+time64 gncInvoiceGetDateDueTT (const GncInvoice *invoice);
 GncBillTerm * gncInvoiceGetTerms (const GncInvoice *invoice);
 const char * gncInvoiceGetBillingID (const GncInvoice *invoice);
 const char * gncInvoiceGetNotes (const GncInvoice *invoice);

commit b5aad8c7bbd25fa5790fa99d64268fad3fa31b4b
Author: lmat <dartme18 at gmail.com>
Date:   Sun Dec 17 04:58:22 2017 -0800

    Renaming time64 function for consistency

diff --git a/libgnucash/engine/Transaction.c b/libgnucash/engine/Transaction.c
index 91bead2..8f434f9 100644
--- a/libgnucash/engine/Transaction.c
+++ b/libgnucash/engine/Transaction.c
@@ -2471,7 +2471,7 @@ xaccTransGetDateDueTS (const Transaction *trans, Timespec *ts)
 }
 
 time64
-xaccTransRetDateDueTime64 (const Transaction *trans)
+xaccTransRetDateDue(const Transaction *trans)
 {
     return xaccTransRetDateDueTS (trans).tv_sec;
 }
diff --git a/libgnucash/engine/Transaction.h b/libgnucash/engine/Transaction.h
index 8492857..6c26c0f 100644
--- a/libgnucash/engine/Transaction.h
+++ b/libgnucash/engine/Transaction.h
@@ -676,7 +676,7 @@ time64        xaccTransRetDateEntered (const Transaction *trans);
 
 /** Dates and txn-type for A/R and A/P "invoice" postings */
 Timespec      xaccTransRetDateDueTS (const Transaction *trans);
-time64        xaccTransRetDateDueTime64 (const Transaction *trans);
+time64        xaccTransRetDateDue (const Transaction *trans);
 /** Dates and txn-type for A/R and A/P "invoice" postings */
 void	      xaccTransGetDateDueTS (const Transaction *trans, Timespec *ts);
 /** @} */

commit 61d4aaaf08b579d56f6201452389dc75484cd391
Author: lmat <dartme18 at gmail.com>
Date:   Sat Dec 16 08:29:25 2017 -0800

    Adding some time64 alternatives

diff --git a/libgnucash/engine/Transaction.c b/libgnucash/engine/Transaction.c
index c838c57..91bead2 100644
--- a/libgnucash/engine/Transaction.c
+++ b/libgnucash/engine/Transaction.c
@@ -2402,6 +2402,12 @@ xaccTransRetDatePostedTS (const Transaction *trans)
     return trans ? trans->date_posted : ts;
 }
 
+time64
+xaccTransRetDatePosted (const Transaction *trans)
+{
+    return trans ? trans->date_posted.tv_sec : 0;
+}
+
 GDate
 xaccTransGetDatePostedGDate (const Transaction *trans)
 {
@@ -2445,6 +2451,12 @@ xaccTransRetDateEnteredTS (const Transaction *trans)
     return trans ? trans->date_entered : ts;
 }
 
+time64
+xaccTransRetDateEntered (const Transaction *trans)
+{
+    return trans ? trans->date_entered.tv_sec : 0;
+}
+
 void
 xaccTransGetDateDueTS (const Transaction *trans, Timespec *ts)
 {
diff --git a/libgnucash/engine/Transaction.h b/libgnucash/engine/Transaction.h
index 5414bd9..8492857 100644
--- a/libgnucash/engine/Transaction.h
+++ b/libgnucash/engine/Transaction.h
@@ -656,6 +656,7 @@ void          xaccTransGetDatePostedTS (const Transaction *trans, Timespec *ts);
     having different function names, GetDate and GetDatePosted refer
     to the same single date.)*/
 Timespec      xaccTransRetDatePostedTS (const Transaction *trans);
+time64        xaccTransRetDatePosted   (const Transaction *trans);
 /** Retrieve the posted date of the transaction. The posted date is
     the date when this transaction was posted at the bank. */
 GDate      xaccTransGetDatePostedGDate (const Transaction *trans);
@@ -671,6 +672,7 @@ void          xaccTransGetDateEnteredTS (const Transaction *trans, Timespec *ts)
 /** Retrieve the date of when the transaction was entered. The entered
  * date is the date when the register entry was made.*/
 Timespec      xaccTransRetDateEnteredTS (const Transaction *trans);
+time64        xaccTransRetDateEntered (const Transaction *trans);
 
 /** Dates and txn-type for A/R and A/P "invoice" postings */
 Timespec      xaccTransRetDateDueTS (const Transaction *trans);
diff --git a/libgnucash/engine/gnc-pricedb.c b/libgnucash/engine/gnc-pricedb.c
index 41088d0..d550f24 100644
--- a/libgnucash/engine/gnc-pricedb.c
+++ b/libgnucash/engine/gnc-pricedb.c
@@ -591,6 +591,13 @@ gnc_price_get_commodity(const GNCPrice *p)
     return p->commodity;
 }
 
+time64
+gnc_price_get_time64(const GNCPrice *p)
+{
+    if (!p) return 0;
+    return p->tmspec.tv_sec;
+}
+
 Timespec
 gnc_price_get_time(const GNCPrice *p)
 {
diff --git a/libgnucash/engine/gnc-pricedb.h b/libgnucash/engine/gnc-pricedb.h
index 671c87e..f2117f8 100644
--- a/libgnucash/engine/gnc-pricedb.h
+++ b/libgnucash/engine/gnc-pricedb.h
@@ -257,6 +257,7 @@ gnc_commodity * gnc_price_get_commodity(const GNCPrice *p);
 /*@ dependent @*/
 gnc_commodity * gnc_price_get_currency(const GNCPrice *p);
 Timespec        gnc_price_get_time(const GNCPrice *p);
+time64          gnc_price_get_time64(const GNCPrice *p);
 PriceSource     gnc_price_get_source(const GNCPrice *p);
 const char *    gnc_price_get_source_string(const GNCPrice *p);
 const char *    gnc_price_get_typestr(const GNCPrice *p);

commit 2f89e4595bfa1cb356f9d94273809aa4f8bc5cd2
Author: lmat <dartme18 at gmail.com>
Date:   Fri Dec 1 16:17:42 2017 -0500

    timespec->time64 for gnc_budget_get_period...

diff --git a/libgnucash/engine/gnc-budget.c b/libgnucash/engine/gnc-budget.c
index a4a2a21..ecd9ca7 100644
--- a/libgnucash/engine/gnc-budget.c
+++ b/libgnucash/engine/gnc-budget.c
@@ -591,25 +591,18 @@ gnc_budget_get_account_period_value(const GncBudget *budget,
 }
 
 
-Timespec
+time64
 gnc_budget_get_period_start_date(const GncBudget *budget, guint period_num)
 {
-    Timespec ts = {0, 0};
-    g_return_val_if_fail (GNC_IS_BUDGET(budget), ts);
-    timespecFromTime64(
-        &ts, recurrenceGetPeriodTime(&GET_PRIVATE(budget)->recurrence,
-                                     period_num, FALSE));
-    return ts;
+    g_return_val_if_fail (GNC_IS_BUDGET(budget), 0);
+    return recurrenceGetPeriodTime(&GET_PRIVATE(budget)->recurrence, period_num, FALSE);
 }
 
-Timespec
+time64
 gnc_budget_get_period_end_date(const GncBudget *budget, guint period_num)
 {
-    Timespec ts = {0, 0};
-    g_return_val_if_fail (GNC_IS_BUDGET(budget), ts);
-    timespecFromTime64(
-        &ts,  recurrenceGetPeriodTime(&GET_PRIVATE(budget)->recurrence, period_num, TRUE));
-    return ts;
+    g_return_val_if_fail (GNC_IS_BUDGET(budget), 0);
+    return recurrenceGetPeriodTime(&GET_PRIVATE(budget)->recurrence, period_num, TRUE);
 }
 
 gnc_numeric
diff --git a/libgnucash/engine/gnc-budget.h b/libgnucash/engine/gnc-budget.h
index 35815d0..5482758 100644
--- a/libgnucash/engine/gnc-budget.h
+++ b/libgnucash/engine/gnc-budget.h
@@ -131,10 +131,10 @@ void gnc_budget_set_recurrence(GncBudget *budget, const Recurrence *r);
 const Recurrence * gnc_budget_get_recurrence(const GncBudget *budget);
 
 /** Get the starting date of the Budget period*/
-Timespec gnc_budget_get_period_start_date(const GncBudget* budget, guint period_num);
+time64 gnc_budget_get_period_start_date(const GncBudget* budget, guint period_num);
 
 /** Get the ending date of the Budget period*/
-Timespec gnc_budget_get_period_end_date(const GncBudget* budget, guint period_num);
+time64 gnc_budget_get_period_end_date(const GncBudget* budget, guint period_num);
 
 /* Period indices are zero-based. */
 void gnc_budget_set_account_period_value(
diff --git a/libgnucash/engine/test/utest-Budget.c b/libgnucash/engine/test/utest-Budget.c
index 7509208..fd311d1 100644
--- a/libgnucash/engine/test/utest-Budget.c
+++ b/libgnucash/engine/test/utest-Budget.c
@@ -2533,8 +2533,8 @@ test_gnc_set_budget_recurrence()
 
     for (i = 0; i < 12; ++i)
     {
-        period_start = timespec_to_gdate(gnc_budget_get_period_start_date(budget, i));
-        period_end = timespec_to_gdate(gnc_budget_get_period_end_date(budget, i));
+        period_start = time64_to_gdate(gnc_budget_get_period_start_date(budget, i));
+        period_end = time64_to_gdate(gnc_budget_get_period_end_date(budget, i));
 
         g_assert_cmpint(g_date_get_day(&period_start), ==, 1);
         g_assert_cmpint(g_date_get_day(&period_end), ==, period_info[i].end_day);

commit 95e31f982bb7e551c5c8be01354737b4d4c0e838
Author: lmat <dartme18 at gmail.com>
Date:   Wed Nov 22 07:40:51 2017 -0500

    Date option absolute now takes time64.

diff --git a/libgnucash/app-utils/option-util.c b/libgnucash/app-utils/option-util.c
index 979de6a..4ec1ba1 100644
--- a/libgnucash/app-utils/option-util.c
+++ b/libgnucash/app-utils/option-util.c
@@ -2512,7 +2512,7 @@ gnc_date_option_value_get_absolute (SCM option_value)
     SCM value;
     initialize_getters();
     value = scm_call_1 (getters.date_option_value_absolute, option_value);
-    return gnc_timepair2timespec (value).tv_sec;
+    return scm_to_int64 (value);
 }
 
 /*******************************************************************\

commit 7d51089501d72095a14a7b8135f36af509deafe4
Author: lmat <dartme18 at gmail.com>
Date:   Tue Nov 21 12:36:36 2017 -0500

    Changing scheme conversion to gdate to use time64

diff --git a/common/base-typemaps.i b/common/base-typemaps.i
index e9f7ac0..7a868a5 100644
--- a/common/base-typemaps.i
+++ b/common/base-typemaps.i
@@ -53,7 +53,7 @@ typedef char gchar;
 %typemap(in) Timespec "$1 = gnc_timepair2timespec($input);"
 %typemap(out) Timespec "$result = gnc_timespec2timepair($1);"
 
-%typemap(in) GDate "$1 = gnc_timepair_to_GDate($input);"
+%typemap(in) GDate "$1 = gnc_time64_to_GDate($input);"
 
 %typemap(in) GncGUID "$1 = gnc_scm2guid($input);"
 %typemap(out) GncGUID "$result = gnc_guid2scm($1);"
diff --git a/libgnucash/engine/engine-helpers-guile.h b/libgnucash/engine/engine-helpers-guile.h
index 218d4f6..ad97e9c 100644
--- a/libgnucash/engine/engine-helpers-guile.h
+++ b/libgnucash/engine/engine-helpers-guile.h
@@ -34,7 +34,7 @@
 
 SCM      gnc_timespec2timepair(Timespec t);
 Timespec gnc_timepair2timespec(SCM x);
-GDate    gnc_timepair_to_GDate(SCM x);
+GDate    gnc_time64_to_GDate(SCM x);
 int      gnc_timepair_p(SCM x);
 
 SCM  gnc_guid2scm(GncGUID guid);
diff --git a/libgnucash/engine/engine-helpers.c b/libgnucash/engine/engine-helpers.c
index f25b160..228075f 100644
--- a/libgnucash/engine/engine-helpers.c
+++ b/libgnucash/engine/engine-helpers.c
@@ -309,10 +309,10 @@ gnc_timepair2timespec(SCM x)
     return(result);
 }
 
-GDate gnc_timepair_to_GDate(SCM x)
+GDate gnc_time64_to_GDate(SCM x)
 {
-    Timespec tspec = gnc_timepair2timespec(x);
-    return timespec_to_gdate(tspec);
+    time64 time = scm_to_int64 (x);
+    return time64_to_gdate(time);
 }
 
 int
diff --git a/libgnucash/engine/gnc-date.h b/libgnucash/engine/gnc-date.h
index 8637cd7..113e4a0 100644
--- a/libgnucash/engine/gnc-date.h
+++ b/libgnucash/engine/gnc-date.h
@@ -346,6 +346,8 @@ void timespecFromTime64 (Timespec *ts, time64 t );
 /** Turns a Timespec into a time64 */
 time64 timespecToTime64 (Timespec ts);
 
+GDate time64_to_gdate (time64 t);
+
 /** Turns a Timespec into a GDate */
 GDate timespec_to_gdate (Timespec ts);
 

commit d36742d941d81eda4c1a8bc96857bb61461d9965
Author: lmat <dartme18 at gmail.com>
Date:   Mon Nov 13 12:32:36 2017 -0800

    Removing uses of timespec

diff --git a/gnucash/register/ledger-core/gncEntryLedgerModel.c b/gnucash/register/ledger-core/gncEntryLedgerModel.c
index a638d06..e62d109 100644
--- a/gnucash/register/ledger-core/gncEntryLedgerModel.c
+++ b/gnucash/register/ledger-core/gncEntryLedgerModel.c
@@ -2,6 +2,7 @@
  * gncEntryLedgerModel.c -- Model for GncEntry ledger
  * Copyright (C) 2001, 2002, 2003 Derek Atkins
  * Author: Derek Atkins <warlord at MIT.EDU>
+ * Copyright (C) 2017 Aaron Laws
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -569,7 +570,6 @@ static char * get_date_help (VirtualLocation virt_loc, gpointer user_data)
     BasicCell *cell;
     char string[1024];
     struct tm tm;
-    Timespec ts;
     time64 tt;
 
     cell = gnc_table_get_cell (ledger->table, virt_loc);
@@ -579,8 +579,7 @@ static char * get_date_help (VirtualLocation virt_loc, gpointer user_data)
     if (!cell->value || *cell->value == '\0')
         return NULL;
 
-    gnc_date_cell_get_date ((DateCell *) cell, &ts);
-    tt = ts.tv_sec;
+    gnc_date_cell_get_date ((DateCell *) cell, &tt);
     gnc_localtime_r (&tt, &tm);
     qof_strftime (string, sizeof(string), _("%A %d %B %Y"), &tm);
 
diff --git a/gnucash/register/ledger-core/split-register-control.c b/gnucash/register/ledger-core/split-register-control.c
index c300e5b..80873cd 100644
--- a/gnucash/register/ledger-core/split-register-control.c
+++ b/gnucash/register/ledger-core/split-register-control.c
@@ -1,5 +1,6 @@
 /********************************************************************\
  * split-register-control.c -- split register control object        *
+ * Copyright (C) 2017 Aaron Laws                                    *
  *                                                                  *
  * This program is free software; you can redistribute it and/or    *
  * modify it under the terms of the GNU General Public License as   *
@@ -1285,9 +1286,9 @@ gnc_split_register_xfer_dialog(SplitRegister *reg, Transaction *txn,
     cell = gnc_cellblock_get_cell_by_name(cur, DATE_CELL, NULL, NULL);
     if (cell)
     {
-        Timespec ts;
-        gnc_date_cell_get_date((DateCell*) cell, &ts);
-        gnc_xfer_dialog_set_date(xfer, timespecToTime64(ts));
+        time64 time;
+        gnc_date_cell_get_date((DateCell*) cell, &time);
+        gnc_xfer_dialog_set_date(xfer, time);
     }
     else
         gnc_xfer_dialog_set_date(xfer, xaccTransGetDate(txn));
diff --git a/gnucash/register/ledger-core/split-register-model-save.c b/gnucash/register/ledger-core/split-register-model-save.c
index 00b02c1..2f7cb19 100644
--- a/gnucash/register/ledger-core/split-register-model-save.c
+++ b/gnucash/register/ledger-core/split-register-model-save.c
@@ -1,5 +1,6 @@
 /********************************************************************\
  * split-register-model-save.c -- split register model object       *
+ * Copyright (C) 2017 Aaron Laws                                    *
  *                                                                  *
  * This program is free software; you can redistribute it and/or    *
  * modify it under the terms of the GNU General Public License as   *
@@ -96,19 +97,16 @@ gnc_split_register_save_due_date_cell (BasicCell * cell,
 {
     SRSaveData *sd = save_data;
     const char *value;
+    time64 time;
     Timespec ts;
-
     g_return_if_fail (gnc_basic_cell_has_name (cell, DDUE_CELL));
-
     value = gnc_basic_cell_get_value (cell);
-
     /* commit any pending changes */
     gnc_date_cell_commit ((DateCell *) cell);
-
     DEBUG ("DATE: %s", value ? value : "(null)");
-
-    gnc_date_cell_get_date ((DateCell *) cell, &ts);
-
+    gnc_date_cell_get_date ((DateCell *) cell, &time);
+    ts.tv_sec = time;
+    ts.tv_nsec = 0;
     xaccTransSetDateDueTS (sd->trans, &ts);
 }
 
diff --git a/gnucash/register/ledger-core/split-register.c b/gnucash/register/ledger-core/split-register.c
index 2e95e08..9b31668 100644
--- a/gnucash/register/ledger-core/split-register.c
+++ b/gnucash/register/ledger-core/split-register.c
@@ -21,6 +21,7 @@
  * split-register.c
  * author Copyright (c) 1998-2000 Linas Vepstas <linas at linas.org>
  * author Copyright (c) 2000-2001 Dave Peticolas <dave at krondo.com>
+ * author Copyright (c) 2017 Aaron Laws
  */
 #include <config.h>
 
@@ -1382,12 +1383,10 @@ gnc_split_register_save_to_scm (SplitRegister *reg,
     if (gnc_table_layout_get_cell_changed (reg->table->layout, DATE_CELL, TRUE))
     {
         BasicCell *cell;
-        Timespec ts;
-
+        time64 time;
         cell = gnc_table_layout_get_cell (reg->table->layout, DATE_CELL);
-        gnc_date_cell_get_date ((DateCell *) cell, &ts);
-
-        gnc_trans_scm_set_date(trans_scm, &ts);
+        gnc_date_cell_get_date ((DateCell *) cell, &time);
+        gnc_trans_scm_set_date(trans_scm, time);
     }
 
     if (gnc_table_layout_get_cell_changed (reg->table->layout, NUM_CELL, TRUE))
@@ -2076,9 +2075,10 @@ record_price (SplitRegister *reg, Account *account, gnc_numeric value,
     GNCPrice *price;
     gnc_numeric price_value;
     int scu = gnc_commodity_get_fraction(curr);
-    Timespec ts;
+    time64 time;
     BasicCell *cell = gnc_table_layout_get_cell (reg->table->layout, DATE_CELL);
     gboolean swap = FALSE;
+    Timespec ts;
 
     /* Only record the price for account types that don't have a
      * "rate" cell. They'll get handled later by
@@ -2086,7 +2086,9 @@ record_price (SplitRegister *reg, Account *account, gnc_numeric value,
      */
     if (gnc_split_reg_has_rate_cell (reg->type))
         return;
-    gnc_date_cell_get_date ((DateCell*)cell, &ts);
+    gnc_date_cell_get_date ((DateCell*)cell, &time);
+    ts.tv_sec = time;
+    ts.tv_nsec = 0;
     price = gnc_pricedb_lookup_day (pricedb, comm, curr, ts);
     if (gnc_commodity_equiv (comm, gnc_price_get_currency (price)))
             swap = TRUE;
diff --git a/gnucash/register/register-core/datecell.h b/gnucash/register/register-core/datecell.h
index fb56881..e49a72f 100644
--- a/gnucash/register/register-core/datecell.h
+++ b/gnucash/register/register-core/datecell.h
@@ -72,6 +72,7 @@
  * HISTORY:
  * Copyright (c) 1998, 1999, 2000 Linas Vepstas <linas at linas.org>
  * Copyright (c) 2000 Dave Peticolas
+ * Copyright (c) 2017 Aaron Laws
  */
 
 #ifndef DATE_CELL_H
@@ -121,9 +122,9 @@ void        gnc_date_cell_commit (DateCell *cell);
 
 /** Set a Timespec to the value in the DateCell.
  * @param cell The DateCell
- * @param ts A Timespec* to which the function will write the date.
+ * @param time A time64* to which the function will write the time.
  */
-void        gnc_date_cell_get_date (DateCell *cell, Timespec *ts);
+void        gnc_date_cell_get_date (DateCell *cell, time64 *time);
 
 /**  Timespec to the value in the DateCell.
  * @param cell The DateCell
diff --git a/gnucash/register/register-gnome/datecell-gnome.c b/gnucash/register/register-gnome/datecell-gnome.c
index 4faa258..604933c 100644
--- a/gnucash/register/register-gnome/datecell-gnome.c
+++ b/gnucash/register/register-gnome/datecell-gnome.c
@@ -28,6 +28,7 @@
  *
  * HISTORY:
  * Copyright (c) 2000 Dave Peticolas <dave at krondo.com>
+ * Copyright (c) 2017 Aaron Laws
  */
 
 #include <config.h>
@@ -686,7 +687,7 @@ gnc_date_cell_enter (BasicCell *bcell,
 static void
 gnc_date_cell_leave (BasicCell *bcell)
 {
-    Timespec ts;
+    time64 time;
     PopBox *box = bcell->gui_private;
 
     date_picker_disconnect_signals ((DateCell *) bcell);
@@ -697,8 +698,8 @@ gnc_date_cell_leave (BasicCell *bcell)
     box->calendar_popped = FALSE;
 
     /* Refresh the date to expand any shortcuts. */
-    gnc_date_cell_get_date ((DateCell *)bcell, &ts);
-    gnc_date_cell_set_value_secs ((DateCell *)bcell, ts.tv_sec);
+    gnc_date_cell_get_date ((DateCell *)bcell, &time);
+    gnc_date_cell_set_value_secs ((DateCell *)bcell, time);
 }
 
 void
@@ -718,17 +719,13 @@ gnc_date_cell_get_date_gdate (DateCell *cell, GDate *date)
 }
 
 void
-gnc_date_cell_get_date (DateCell *cell, Timespec *ts)
+gnc_date_cell_get_date (DateCell *cell, time64 *time)
 {
     PopBox *box = cell->cell.gui_private;
-
-    if (!cell || !ts)
+    if (!cell || !time)
         return;
-
     gnc_parse_date (&(box->date), cell->cell.value);
-
-    ts->tv_sec = gnc_mktime (&box->date);
-    ts->tv_nsec = 0;
+    *time = gnc_mktime (&box->date);
 }
 
 static void
diff --git a/libgnucash/app-utils/guile-util.c b/libgnucash/app-utils/guile-util.c
index 68325d0..1d2b00a 100644
--- a/libgnucash/app-utils/guile-util.c
+++ b/libgnucash/app-utils/guile-util.c
@@ -2,6 +2,7 @@
  * guile-util.c -- utility functions for using guile for GnuCash    *
  * Copyright (C) 1999 Linas Vepstas                                 *
  * Copyright (C) 2000 Dave Peticolas                                *
+ * Copyright (C) 2017 Aaron Laws                                    *
  *                                                                  *
  * This program is free software; you can redistribute it and/or    *
  * modify it under the terms of the GNU General Public License as   *
@@ -707,19 +708,14 @@ gnc_copy_trans_scm_onto_trans_swap_accounts(SCM trans_scm,
  * Returns: Nothing                                                 *
 \********************************************************************/
 void
-gnc_trans_scm_set_date(SCM trans_scm, Timespec *ts)
+gnc_trans_scm_set_date(SCM trans_scm, time64 time)
 {
     SCM arg;
-
+    Timespec ts = {time, 0};
     initialize_scm_functions();
-
     if (!gnc_is_trans_scm(trans_scm))
         return;
-    if (ts == NULL)
-        return;
-
-    arg = gnc_timespec2timepair(*ts);
-
+    arg = gnc_timespec2timepair(ts);
     scm_call_2(setters.trans_scm_date, trans_scm, arg);
 }
 
diff --git a/libgnucash/app-utils/guile-util.h b/libgnucash/app-utils/guile-util.h
index 338c2ac..9623172 100644
--- a/libgnucash/app-utils/guile-util.h
+++ b/libgnucash/app-utils/guile-util.h
@@ -1,6 +1,7 @@
 /********************************************************************\
  * guile-util.h -- utility functions for using guile for GnuCash    *
  * Copyright (C) 1999 Linas Vepstas                                 *
+ * Copyright (C) 2017 Aaron Laws                                    *
  *                                                                  *
  * This program is free software; you can redistribute it and/or    *
  * modify it under the terms of the GNU General Public License as   *
@@ -67,7 +68,7 @@ void   gnc_copy_trans_scm_onto_trans_swap_accounts(SCM trans_scm,
         gboolean do_commit,
         QofBook *book);
 
-void   gnc_trans_scm_set_date(SCM trans_scm, Timespec *ts);
+void   gnc_trans_scm_set_date(SCM trans_scm, time64 time);
 void   gnc_trans_scm_set_num(SCM trans_scm, const char *num);
 void   gnc_trans_scm_set_description(SCM trans_scm, const char *description);
 void   gnc_trans_scm_set_notes(SCM trans_scm, const char *notes);

commit e947214960c7ff26f7697656cfc29d8c0ca08972
Author: lmat <dartme18 at gmail.com>
Date:   Mon Nov 13 12:10:39 2017 -0800

    Removing uses of timespec

diff --git a/gnucash/gnome-utils/dialog-options.c b/gnucash/gnome-utils/dialog-options.c
index c184208..3504c77 100644
--- a/gnucash/gnome-utils/dialog-options.c
+++ b/gnucash/gnome-utils/dialog-options.c
@@ -3249,13 +3249,13 @@ gnc_option_set_ui_value_date (GNCOption *option, gboolean use_default,
             }
             else if (g_strcmp0(symbol_str, "absolute") == 0)
             {
-                Timespec ts;
+                time64 time;
 
-                ts = gnc_date_option_value_get_absolute (value);
+                time = gnc_date_option_value_get_absolute (value);
 
                 if (g_strcmp0(date_option_type, "absolute") == 0)
                 {
-                    gnc_date_edit_set_time(GNC_DATE_EDIT(widget), ts.tv_sec);
+                    gnc_date_edit_set_time(GNC_DATE_EDIT(widget), time);
                 }
                 else if (g_strcmp0(date_option_type, "both") == 0)
                 {
@@ -3267,7 +3267,7 @@ gnc_option_set_ui_value_date (GNCOption *option, gboolean use_default,
                                                 GNC_RD_WID_AB_WIDGET_POS);
                     g_list_free(widget_list);
                     gnc_date_option_set_select_method(option, TRUE, TRUE);
-                    gnc_date_edit_set_time(GNC_DATE_EDIT(ab_widget), ts.tv_sec);
+                    gnc_date_edit_set_time(GNC_DATE_EDIT(ab_widget), time);
                 }
                 else
                 {
diff --git a/libgnucash/app-utils/option-util.c b/libgnucash/app-utils/option-util.c
index a620460..979de6a 100644
--- a/libgnucash/app-utils/option-util.c
+++ b/libgnucash/app-utils/option-util.c
@@ -1,6 +1,7 @@
 /********************************************************************\
  * option-util.c -- GNOME<->guile option interface                  *
  * Copyright (C) 2000 Dave Peticolas                                *
+ * Copyright (C) 2017 Aaron Laws                                    *
  *                                                                  *
  * This program is free software; you can redistribute it and/or    *
  * modify it under the terms of the GNU General Public License as   *
@@ -2503,18 +2504,15 @@ gnc_date_option_value_get_type (SCM option_value)
  *   get the absolute time of a date option value                  *
  *                                                                 *
  * Args: option_value - option value to get absolute time of       *
- * Return: Timespec value                                          *
+ * Return: time64 value                                            *
 \*******************************************************************/
-Timespec
+time64
 gnc_date_option_value_get_absolute (SCM option_value)
 {
     SCM value;
-
     initialize_getters();
-
     value = scm_call_1 (getters.date_option_value_absolute, option_value);
-
-    return gnc_timepair2timespec (value);
+    return gnc_timepair2timespec (value).tv_sec;
 }
 
 /*******************************************************************\
diff --git a/libgnucash/app-utils/option-util.h b/libgnucash/app-utils/option-util.h
index b4cea26..d35692c 100644
--- a/libgnucash/app-utils/option-util.h
+++ b/libgnucash/app-utils/option-util.h
@@ -2,6 +2,7 @@
  * option-util.h -- GNOME<->guile option interface                  *
  * Copyright (C) 1998,1999 Linas Vepstas                            *
  * Copyright (C) 2000 Dave Peticolas                                *
+ * Copyright (C) 2017 Aaron Laws                                    *
  *                                                                  *
  * This program is free software; you can redistribute it and/or    *
  * modify it under the terms of the GNU General Public License as   *
@@ -240,7 +241,7 @@ gboolean gnc_option_db_set_string_option(GNCOptionDB *odb,
 char * gnc_option_date_option_get_subtype(GNCOption *option);
 
 char * gnc_date_option_value_get_type (SCM option_value);
-Timespec gnc_date_option_value_get_absolute (SCM option_value);
+time64 gnc_date_option_value_get_absolute (SCM option_value);
 SCM gnc_date_option_value_get_relative (SCM option_value);
 
 char * gnc_plot_size_option_value_get_type (SCM option_value);

commit 168f6d6740348f41db7867497933e2c0cea9db44
Author: lmat <dartme18 at gmail.com>
Date:   Mon Nov 13 14:40:48 2017 -0500

    Removing unused timespec function

diff --git a/libgnucash/app-utils/option-util.c b/libgnucash/app-utils/option-util.c
index ad84b7f..a620460 100644
--- a/libgnucash/app-utils/option-util.c
+++ b/libgnucash/app-utils/option-util.c
@@ -2085,112 +2085,6 @@ gnc_option_db_lookup_multichoice_option(GNCOptionDB *odb,
     return strdup(default_value);
 }
 
-
-/********************************************************************\
- * gnc_option_db_lookup_date_option                                 *
- *   looks up a date option. If present, returns the absolute date  *
- *   represented in the set_ab_value argument provided, otherwise   *
- *   copies the default_value argument (if non-NULL) to the         *
- *   set_ab_value argument. If the default_value argument is NULL,  *
- *   copies the current date to set_ab_value. Whatever value is     *
- *   stored in set_ab_value is returned as an approximate (no       *
- *   nanoseconds) time64 value.  set_ab_value may be NULL, in which *
- *   case only the return value can be used. If is_relative is      *
- *   non-NULL, it is set to whether the date option is currently    *
- *   storing a relative date.  If it is, and set_rel_value          *
- *   is non-NULL, it returns a newly allocated string               *
- *   representing the scheme symbol for that relative date          *
- *                                                                  *
- * Args: odb           - option database to search in               *
- *       section       - section name of option                     *
- *       name          - name of option                             *
- *       is_relative   - location to store boolean value            *
- *       set_ab_value  - location to store absolute option value    *
- *       set_rel_value - location to store relative option value    *
- *       default       - default value if not found                 *
- * Return: time64 approximation of set_value                        *
-\********************************************************************/
-time64
-gnc_option_db_lookup_date_option(GNCOptionDB *odb,
-                                 const char *section,
-                                 const char *name,
-                                 gboolean *is_relative,
-                                 Timespec *set_ab_value,
-                                 char **set_rel_value,
-                                 Timespec *default_value)
-{
-    GNCOption *option;
-    Timespec temp = {0, 0};
-    char *symbol;
-    SCM getter;
-    SCM value;
-
-    initialize_getters();
-
-    if (set_ab_value == NULL)
-    {
-        set_ab_value = &temp;
-    }
-
-    if (set_rel_value != NULL)
-    {
-        *set_rel_value = NULL;
-    }
-
-    if (is_relative != NULL)
-    {
-        *is_relative = FALSE;
-    }
-
-    option = gnc_option_db_get_option_by_name(odb, section, name);
-
-    if (option != NULL)
-    {
-        getter = gnc_option_getter(option);
-        if (getter != SCM_UNDEFINED)
-        {
-            value = scm_call_0(getter);
-
-            if (scm_is_pair(value))
-            {
-                Timespec absolute;
-
-                absolute = gnc_date_option_value_get_absolute (value);
-
-                *set_ab_value = absolute;
-
-                symbol = gnc_date_option_value_get_type (value);
-
-                if (g_strcmp0(symbol, "relative") == 0)
-                {
-                    SCM relative = gnc_date_option_value_get_relative (value);
-
-                    if (is_relative != NULL)
-                        *is_relative = TRUE;
-
-                    if (set_rel_value != NULL)
-                        *set_rel_value = gnc_scm_symbol_to_locale_string (relative);
-                }
-
-                g_free (symbol);
-            }
-        }
-    }
-    else
-    {
-        if (default_value == NULL)
-        {
-            set_ab_value->tv_sec = gnc_time (NULL);
-            set_ab_value->tv_nsec = 0;
-        }
-        else
-            *set_ab_value = *default_value;
-    }
-
-    return set_ab_value->tv_sec;
-}
-
-
 /********************************************************************\
  * gnc_option_db_lookup_number_option                               *
  *   looks up a number option. If present, returns its value        *
diff --git a/libgnucash/app-utils/option-util.h b/libgnucash/app-utils/option-util.h
index 32e1080..b4cea26 100644
--- a/libgnucash/app-utils/option-util.h
+++ b/libgnucash/app-utils/option-util.h
@@ -182,14 +182,6 @@ char * gnc_option_db_lookup_multichoice_option(GNCOptionDB *odb,
         const char *name,
         const char *default_value);
 
-time64 gnc_option_db_lookup_date_option(GNCOptionDB *odb,
-                                        const char *section,
-                                        const char *name,
-                                        gboolean *is_relative,
-                                        Timespec *set_ab_value,
-                                        char **set_rel_value,
-                                        Timespec *default_value);
-
 gdouble gnc_option_db_lookup_number_option(GNCOptionDB *odb,
         const char *section,
         const char *name,

commit ee56f5df7894b031057e331aed360da1e9b05f0b
Author: lmat <dartme18 at gmail.com>
Date:   Sat Nov 11 20:19:30 2017 -0500

    Adding some time64 API functions

diff --git a/libgnucash/engine/Transaction.c b/libgnucash/engine/Transaction.c
index 17e019e..c838c57 100644
--- a/libgnucash/engine/Transaction.c
+++ b/libgnucash/engine/Transaction.c
@@ -2458,6 +2458,12 @@ xaccTransGetDateDueTS (const Transaction *trans, Timespec *ts)
         xaccTransGetDatePostedTS (trans, ts);
 }
 
+time64
+xaccTransRetDateDueTime64 (const Transaction *trans)
+{
+    return xaccTransRetDateDueTS (trans).tv_sec;
+}
+
 Timespec
 xaccTransRetDateDueTS (const Transaction *trans)
 {
diff --git a/libgnucash/engine/Transaction.h b/libgnucash/engine/Transaction.h
index 2d14389..5414bd9 100644
--- a/libgnucash/engine/Transaction.h
+++ b/libgnucash/engine/Transaction.h
@@ -674,6 +674,7 @@ Timespec      xaccTransRetDateEnteredTS (const Transaction *trans);
 
 /** Dates and txn-type for A/R and A/P "invoice" postings */
 Timespec      xaccTransRetDateDueTS (const Transaction *trans);
+time64        xaccTransRetDateDueTime64 (const Transaction *trans);
 /** Dates and txn-type for A/R and A/P "invoice" postings */
 void	      xaccTransGetDateDueTS (const Transaction *trans, Timespec *ts);
 /** @} */
diff --git a/libgnucash/engine/engine.i b/libgnucash/engine/engine.i
index 4604f25..fe307ce 100644
--- a/libgnucash/engine/engine.i
+++ b/libgnucash/engine/engine.i
@@ -208,6 +208,7 @@ SplitList * qof_query_run_subquery (QofQuery *q, const QofQuery *q);
 %include <gnc-numeric.h>
 
 Timespec timespecCanonicalDayTime(Timespec t);
+time64 time64CanonicalDayTime(time64 t);
 
 %include <gnc-budget.h>
 
diff --git a/libgnucash/engine/gnc-date.cpp b/libgnucash/engine/gnc-date.cpp
index 0c7b774..86e56b7 100644
--- a/libgnucash/engine/gnc-date.cpp
+++ b/libgnucash/engine/gnc-date.cpp
@@ -486,6 +486,15 @@ timespecCanonicalDayTime(Timespec t)
     return retval;
 }
 
+time64
+time64CanonicalDayTime (time64 t)
+{
+    struct tm tm;
+    gnc_localtime_r(&t, &tm);
+    gnc_tm_set_day_middle(&tm);
+    return gnc_mktime (&tm);
+}
+
 /* NB: month is 1-12, year is 0001 - 9999. */
 int gnc_date_get_last_mday (int month, int year)
 {
diff --git a/libgnucash/engine/gnc-date.h b/libgnucash/engine/gnc-date.h
index 7d15b31..8637cd7 100644
--- a/libgnucash/engine/gnc-date.h
+++ b/libgnucash/engine/gnc-date.h
@@ -335,6 +335,8 @@ Timespec timespec_abs(const Timespec *t);
  * returning a Timespec. */
 Timespec timespecCanonicalDayTime(Timespec t);
 
+time64 time64CanonicalDayTime(time64 t);
+
 /** Returns the current clock time as a Timespec, taken from time(2). */
 Timespec timespec_now (void);
 



Summary of changes:
 bindings/python/CMakeLists.txt                     |   4 +-
 bindings/python/gnucash_core.i                     |   2 +-
 bindings/python/tests/test_account.py              |   4 +-
 bindings/python/tests/test_business.py             |   4 +-
 bindings/python/time64.i                           |  83 ++++++
 bindings/python/timespec.i                         |  73 ------
 common/base-typemaps.i                             |   5 +-
 gnucash/gnome-utils/dialog-options.c               |  24 +-
 gnucash/gnome-utils/dialog-transfer.c              |   2 +-
 gnucash/gnome-utils/gnc-tree-control-split-reg.c   |  22 +-
 gnucash/gnome-utils/gnc-tree-model-split-reg.c     |   3 +-
 gnucash/gnome-utils/gnc-tree-util-split-reg.c      |   2 +-
 gnucash/gnome-utils/gnc-tree-view-split-reg.c      |  29 +--
 gnucash/gnome/dialog-date-close.c                  |   6 +-
 gnucash/gnome/dialog-invoice.c                     |  30 +--
 gnucash/gnome/dialog-payment.c                     |   6 +-
 gnucash/gnome/dialog-trans-assoc.c                 |   3 +-
 gnucash/gnome/gnc-plugin-business.c                |  24 +-
 gnucash/import-export/bi-import/dialog-bi-import.c |  22 +-
 gnucash/import-export/csv-imp/gnc-trans-props.cpp  |   4 +-
 gnucash/import-export/log-replay/gnc-log-replay.c  |  16 +-
 .../import-export/qif-imp/assistant-qif-import.c   |   8 +-
 gnucash/import-export/qif-imp/qif-merge-groups.scm |   8 +-
 gnucash/register/ledger-core/gncEntryLedger.c      |  18 +-
 .../register/ledger-core/gncEntryLedgerControl.c   |   6 +-
 gnucash/register/ledger-core/gncEntryLedgerModel.c |   9 +-
 .../register/ledger-core/split-register-control.c  |   7 +-
 .../ledger-core/split-register-model-save.c        |  13 +-
 .../register/ledger-core/split-register-model.c    |   8 +-
 gnucash/register/ledger-core/split-register.c      |  16 +-
 gnucash/register/register-core/datecell.h          |   5 +-
 gnucash/register/register-gnome/datecell-gnome.c   |  17 +-
 gnucash/report/business-reports/aging.scm          |  14 +-
 .../report/business-reports/balsheet-eg.eguile.scm |   4 +-
 gnucash/report/business-reports/balsheet-eg.scm    |   7 +-
 .../report/business-reports/customer-summary.scm   |  22 +-
 gnucash/report/business-reports/easy-invoice.scm   |   8 +-
 gnucash/report/business-reports/fancy-invoice.scm  |  12 +-
 gnucash/report/business-reports/invoice.scm        |  10 +-
 gnucash/report/business-reports/job-report.scm     |  26 +-
 gnucash/report/business-reports/owner-report.scm   |  28 +-
 gnucash/report/business-reports/receipt.eguile.scm |  10 +-
 .../report/business-reports/taxinvoice.eguile.scm  |  14 +-
 gnucash/report/locale-specific/us/taxtxf-de_DE.scm |  75 +++---
 gnucash/report/locale-specific/us/taxtxf.scm       |  97 ++++---
 gnucash/report/report-system/collectors.scm        |  23 --
 .../report/report-system/commodity-utilities.scm   | 104 ++++----
 gnucash/report/report-system/html-acct-table.scm   |   7 +-
 gnucash/report/report-system/report-collectors.scm |  61 ++---
 gnucash/report/report-system/report-utilities.scm  |  56 ++--
 .../report-system/test/test-report-utilities.scm   |  23 +-
 .../report/standard-reports/account-piecharts.scm  |  25 +-
 .../report/standard-reports/account-summary.scm    |  15 +-
 .../report/standard-reports/advanced-portfolio.scm |  14 +-
 .../report/standard-reports/average-balance.scm    |  33 ++-
 gnucash/report/standard-reports/balance-sheet.scm  |  33 ++-
 .../standard-reports/budget-balance-sheet.scm      |   6 +-
 .../report/standard-reports/budget-barchart.scm    |  18 +-
 gnucash/report/standard-reports/budget-flow.scm    |   2 +-
 .../standard-reports/budget-income-statement.scm   |   4 +-
 gnucash/report/standard-reports/budget.scm         |   6 +-
 gnucash/report/standard-reports/cash-flow.scm      |  34 +--
 .../report/standard-reports/cashflow-barchart.scm  |  48 ++--
 .../report/standard-reports/category-barchart.scm  |  42 +--
 gnucash/report/standard-reports/daily-reports.scm  |  61 ++---
 .../report/standard-reports/equity-statement.scm   |  50 ++--
 .../standard-reports/income-gst-statement.scm      |  98 +++----
 .../report/standard-reports/income-statement.scm   |  38 ++-
 gnucash/report/standard-reports/net-barchart.scm   |  27 +-
 gnucash/report/standard-reports/net-linechart.scm  |  24 +-
 gnucash/report/standard-reports/portfolio.scm      |   4 +-
 gnucash/report/standard-reports/price-scatter.scm  |  44 ++--
 gnucash/report/standard-reports/register.scm       |   6 +-
 gnucash/report/standard-reports/sx-summary.scm     |  21 +-
 .../standard-reports/test/test-cash-flow.scm       |  39 ++-
 .../test/test-cashflow-barchart.scm                |  16 +-
 .../test/test-generic-net-barchart.scm             |  18 +-
 .../test/test-generic-net-linechart.scm            |   8 +-
 gnucash/report/standard-reports/transaction.scm    |  10 +-
 gnucash/report/standard-reports/trial-balance.scm  |  35 ++-
 gnucash/report/stylesheets/stylesheet-easy.scm     |   4 +-
 gnucash/report/stylesheets/stylesheet-fancy.scm    |   4 +-
 gnucash/report/stylesheets/stylesheet-footer.scm   |   4 +-
 .../report/stylesheets/stylesheet-head-or-tail.scm |   8 +-
 gnucash/report/utility-reports/hello-world.scm     |  14 +-
 libgnucash/app-utils/app-utils.scm                 |  45 ++--
 libgnucash/app-utils/date-utilities.scm            | 283 ++++++++-------------
 libgnucash/app-utils/guile-util.c                  |  12 +-
 libgnucash/app-utils/guile-util.h                  |   3 +-
 libgnucash/app-utils/option-util.c                 | 116 +--------
 libgnucash/app-utils/option-util.h                 |  11 +-
 libgnucash/app-utils/options.scm                   |  25 +-
 libgnucash/backend/xml/gnc-entry-xml-v2.cpp        |  26 +-
 libgnucash/backend/xml/gnc-invoice-xml-v2.cpp      |  32 +--
 libgnucash/backend/xml/gnc-order-xml-v2.cpp        |  12 +-
 libgnucash/backend/xml/gnc-pricedb-xml-v2.cpp      |   9 +-
 libgnucash/backend/xml/gnc-transaction-xml-v2.cpp  |  53 ++--
 libgnucash/backend/xml/io-gncxml-v1.cpp            |  19 +-
 libgnucash/backend/xml/sixtp-dom-generators.cpp    |  43 +---
 libgnucash/backend/xml/sixtp-dom-generators.h      |   5 +-
 libgnucash/backend/xml/sixtp-dom-parsers.cpp       |  75 ++----
 libgnucash/backend/xml/sixtp-dom-parsers.h         |   4 +-
 libgnucash/backend/xml/sixtp-utils.cpp             |  71 ++----
 libgnucash/backend/xml/sixtp-utils.h               |  10 +-
 .../backend/xml/test/test-date-converting.cpp      |  37 +--
 .../backend/xml/test/test-dom-converters1.cpp      |  27 +-
 libgnucash/backend/xml/test/test-file-stuff.cpp    |  13 +-
 libgnucash/backend/xml/test/test-file-stuff.h      |   2 +-
 .../backend/xml/test/test-xml-transaction.cpp      |   4 +-
 libgnucash/engine/Account.cpp                      |   8 +-
 libgnucash/engine/Query.c                          |  10 +-
 libgnucash/engine/Scrub.c                          |   6 +-
 libgnucash/engine/Split.c                          |   8 +-
 libgnucash/engine/TransLog.c                       |  14 +-
 libgnucash/engine/Transaction.c                    | 202 +++++++--------
 libgnucash/engine/Transaction.h                    |  31 +--
 libgnucash/engine/TransactionP.h                   |   4 +-
 libgnucash/engine/cap-gains.c                      |  11 +-
 libgnucash/engine/engine-helpers-guile.h           |   2 +-
 libgnucash/engine/engine-helpers.c                 |  18 +-
 libgnucash/engine/engine-interface.scm             |   9 +-
 libgnucash/engine/engine.i                         |   1 +
 libgnucash/engine/gnc-budget.c                     |  19 +-
 libgnucash/engine/gnc-budget.h                     |   4 +-
 libgnucash/engine/gnc-date.cpp                     |  67 ++++-
 libgnucash/engine/gnc-date.h                       |  21 +-
 libgnucash/engine/gnc-pricedb.c                    |  64 +++++
 libgnucash/engine/gnc-pricedb.h                    |  14 +
 libgnucash/engine/gncBillTerm.c                    |  12 +-
 libgnucash/engine/gncBillTerm.h                    |   2 +-
 libgnucash/engine/gncEntry.c                       |  57 ++---
 libgnucash/engine/gncEntry.h                       |   8 +-
 libgnucash/engine/gncInvoice.c                     |  82 +++---
 libgnucash/engine/gncInvoice.h                     |  16 +-
 libgnucash/engine/gncOwner.c                       |  39 ++-
 libgnucash/engine/policy.c                         |  12 +-
 libgnucash/engine/test-core/test-engine-stuff.cpp  |  33 +--
 libgnucash/engine/test-core/test-engine-stuff.h    |   1 +
 libgnucash/engine/test/test-date.cpp               |  22 +-
 libgnucash/engine/test/test-extras.scm             |  12 +-
 libgnucash/engine/test/test-gnc-date.c             |  16 +-
 libgnucash/engine/test/test-split.scm              |   2 +-
 .../engine/test/test-transaction-voiding.cpp       |  12 +-
 libgnucash/engine/test/utest-Budget.c              |   4 +-
 libgnucash/engine/test/utest-Entry.c               |   6 +-
 libgnucash/engine/test/utest-Invoice.c             |   5 +-
 libgnucash/engine/test/utest-Split.cpp             |  12 +-
 libgnucash/engine/test/utest-Transaction.cpp       | 115 ++++-----
 libgnucash/scm/price-quotes.scm                    |  17 +-
 149 files changed, 1726 insertions(+), 2106 deletions(-)
 create mode 100644 bindings/python/time64.i
 delete mode 100644 bindings/python/timespec.i



More information about the gnucash-changes mailing list