gnucash unstable: Multiple changes pushed

John Ralls jralls at code.gnucash.org
Sat Dec 30 16:40:23 EST 2017


Updated	 via  https://github.com/Gnucash/gnucash/commit/7feb9c65 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/d06ed7c1 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/3d2682ac (commit)
	 via  https://github.com/Gnucash/gnucash/commit/82f1384c (commit)
	 via  https://github.com/Gnucash/gnucash/commit/40654cf5 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/44c51f43 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a28bcdf1 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a847d441 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/9af6f184 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/302d1e73 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/98fcf1b0 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/3f408a88 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/b6ec61fa (commit)
	 via  https://github.com/Gnucash/gnucash/commit/f3bc8eea (commit)
	from  https://github.com/Gnucash/gnucash/commit/d6bb34ef (commit)



commit 7feb9c65cf45e09f9f27c8197f09328139432395
Author: John Ralls <jralls at ceridwen.us>
Date:   Sat Dec 30 13:40:14 2017 -0800

    Fix distcheck errors.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 867b577..4683798 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -821,7 +821,7 @@ ADD_CUSTOM_COMMAND(OUTPUT ${DIST_FILE}.gz ${DIST_FILE}.bz2
            -P ${CMAKE_SOURCE_DIR}/common/cmake_modules/MakeDist.cmake
 
         DEPENDS
-          ${ALL_DIST} ${DIST_GENERATED_FILES2} gnc-vcs-info iso-4217-c gnc-warnings-c build-config-scm gnucash-design-info ChangeLog
+          ${ALL_DIST} ${DIST_GENERATED_FILES2} gnc-vcs-info iso-4217-c gnc-warnings-c gnucash-design-info ChangeLog
         )
 
 ADD_CUSTOM_TARGET(dist DEPENDS ${DIST_FILE}.gz ${DIST_FILE}.bz2)
diff --git a/gnucash/report/report-system/CMakeLists.txt b/gnucash/report/report-system/CMakeLists.txt
index d97f5be..d8c4a77 100644
--- a/gnucash/report/report-system/CMakeLists.txt
+++ b/gnucash/report/report-system/CMakeLists.txt
@@ -111,8 +111,11 @@ GNC_ADD_SCHEME_TARGETS(scm-report-system-3
   FALSE
 )
 
-SET_LOCAL_DIST(report_system_DIST_local CMakeLists.txt Makefile.am report-system.i
-        ${report_system_HEADERS} ${report_system_SOURCES} ${report_system_SCHEME} ${report_system_SCHEME_1}
-        ${report_system_SCHEME_2} ${report_system_SCHEME_3})
+SET_LOCAL_DIST(report_system_DIST_local CMakeLists.txt Makefile.am
+  report-system.i
+  ${report_system_HEADERS} ${report_system_SOURCES}
+  ${report_system_SCHEME} ${report_system_SCHEME_1}
+  ${report_system_SCHEME_2a} ${report_system_SCHEME_2b}
+  ${report_system_SCHEME_3})
 
 SET(report_system_DIST ${report_system_DIST_local} ${test_report_system_DIST} PARENT_SCOPE)

commit d06ed7c1a8fafe473fcf786fd565ab7eea5c6c7e
Author: John Ralls <jralls at ceridwen.us>
Date:   Sat Dec 30 13:39:55 2017 -0800

    Fix -Wsign-compare error.

diff --git a/libgnucash/engine/test/test-kvp-frame.cpp b/libgnucash/engine/test/test-kvp-frame.cpp
index 4a57c45..9e0491c 100644
--- a/libgnucash/engine/test/test-kvp-frame.cpp
+++ b/libgnucash/engine/test/test-kvp-frame.cpp
@@ -201,16 +201,16 @@ TEST (KvpFrameTestForEachPrefix, for_each_prefix_1)
     unsigned count {};
     auto counter = [] (char const *, KvpValue*, unsigned & count) { ++count; };
     fr.for_each_slot_prefix("one", counter, count);
-    EXPECT_EQ(count, 3);
+    EXPECT_EQ(count, UINT32_C(3));
     count = 0;
     fr.for_each_slot_prefix("onetwo", counter, count);
-    EXPECT_EQ(count, 2);
+    EXPECT_EQ(count, UINT32_C(2));
     count = 0;
     fr.for_each_slot_prefix("onetwothree", counter, count);
-    EXPECT_EQ(count, 1);
+    EXPECT_EQ(count, UINT32_C(1));
     count = 0;
     fr.for_each_slot_prefix("two", counter, count);
-    EXPECT_EQ(count, 0);
+    EXPECT_EQ(count, UINT32_C(0));
 }
 
 TEST (KvpFrameTestForEachPrefix, for_each_prefix_2)

commit 3d2682ac046e8476bc33f4982453eca7e796637c
Merge: d6bb34e 82f1384
Author: John Ralls <jralls at ceridwen.us>
Date:   Sat Dec 30 13:33:43 2017 -0800

    Merge branch 'maint' into unstable

diff --cc libgnucash/app-utils/test/CMakeLists.txt
index c455423,0000000..e343331
mode 100644,000000..100644
--- a/libgnucash/app-utils/test/CMakeLists.txt
+++ b/libgnucash/app-utils/test/CMakeLists.txt
@@@ -1,75 -1,0 +1,76 @@@
 +
 +SET(APP_UTILS_TEST_INCLUDE_DIRS
 +  ${CMAKE_BINARY_DIR}/common # for config.h
 +  ${CMAKE_SOURCE_DIR}/common/test-core
 +  ${CMAKE_SOURCE_DIR}/libgnucash/app-utils
 +  ${CMAKE_SOURCE_DIR}/libgnucash/engine # for qof.h
 +  ${CMAKE_SOURCE_DIR}/libgnucash/engine/test-core
 +  ${GIO_INCLUDE_DIRS}
 +  ${GUILE_INCLUDE_DIRS}
 +)
 +
 +SET(APP_UTILS_TEST_LIBS gncmod-app-utils gncmod-test-engine test-core ${GIO_LDFLAGS} ${GUILE_LDFLAGS})
 +
 +SET(test_app_utils_SOURCES test-app-utils.c test-option-util.cpp test-gnc-ui-util.c)
 +
 +MACRO(ADD_APP_UTILS_TEST _TARGET _SOURCE_FILES)
 +  GNC_ADD_TEST(${_TARGET} "${_SOURCE_FILES}" APP_UTILS_TEST_INCLUDE_DIRS APP_UTILS_TEST_LIBS)
 +ENDMACRO()
 +
 +ADD_APP_UTILS_TEST(test-exp-parser test-exp-parser.c)
 +GNC_ADD_TEST_WITH_GUILE(test-link-module-app-utils test-link-module APP_UTILS_TEST_INCLUDE_DIRS APP_UTILS_TEST_LIBS)
 +ADD_APP_UTILS_TEST(test-print-parse-amount test-print-parse-amount.cpp)
 +# This test not run in autotools build.
 +#GNC_ADD_TEST_WITH_GUILE(test-print-queries test-print-queries.cpp APP_UTILS_TEST_INCLUDE_DIRS APP_UTILS_TEST_LIBS)
 +GNC_ADD_TEST_WITH_GUILE(test-scm-query-string test-scm-query-string.cpp
 +  APP_UTILS_TEST_INCLUDE_DIRS APP_UTILS_TEST_LIBS
 +)
 +ADD_APP_UTILS_TEST(test-sx test-sx.cpp)
 +
 +SET(GUILE_DEPENDS
 +  scm-test-engine
 +  scm-app-utils
 +  gnc-core-utils
 +  gnc-module
 +  gncmod-engine
 +  gncmod-backend-xml
 +  gncmod-backend-xml
 +)
 +
 +set(test_app_utils_scheme_SOURCES
 +  test-c-interface.scm
 +  test-load-app-utils-module.scm
++  test-date-utilities.scm
 +)
 +
 +GNC_ADD_SCHEME_TARGETS(scm-test-load-app-utils-module
 +  "test-load-app-utils-module.scm"
 +  "gnucash/reports"
 +  "${GUILE_DEPENDS}"
 +  FALSE
 +)
 +
 +GNC_ADD_SCHEME_TARGETS(scm-test-c-interface
 +  "test-c-interface.scm"
 +  ""
 +  "${GUILE_DEPENDS}"
 +  FALSE
 +)
 +
 +GNC_ADD_SCHEME_TESTS(${test_app_utils_scheme_SOURCES})
 +# Doesn't work yet:
 +GNC_ADD_TEST_WITH_GUILE(test-app-utils "${test_app_utils_SOURCES}" APP_UTILS_TEST_INCLUDE_DIRS APP_UTILS_TEST_LIBS)
 +
 +SET_DIST_LIST(test_app_utils_DIST
 +  CMakeLists.txt
 +  Makefile.am
 +  test-exp-parser.c
 +  test-link-module.c
 +  test-print-parse-amount.cpp
 +  test-print-queries.cpp
 +  test-scm-query-string.cpp
 +  test-sx.cpp
 +  test-c-interface.scm
 +  ${test_app_utils_scheme_SOURCES}
 +  ${test_app_utils_SOURCES}
 +)
diff --cc libgnucash/app-utils/test/Makefile.am
index 3ebb930,0000000..5a25f24
mode 100644,000000..100644
--- a/libgnucash/app-utils/test/Makefile.am
+++ b/libgnucash/app-utils/test/Makefile.am
@@@ -1,87 -1,0 +1,87 @@@
 +include $(top_srcdir)/test-templates/Makefile.decl
 +
 +check_PROGRAMS = \
 +  test-link-module \
 +  test-exp-parser \
 +  test-scm-query-string \
 +  test-print-parse-amount \
 +  test-sx \
 +  test-app-utils
 +
 +TESTS =  \
 +  ${check_PROGRAMS} \
 +  ${SCM_TESTS}
 +
 +test_scm_query_string_SOURCES = test-scm-query-string.cpp
 +test_sx_SOURCES = test-sx.cpp
 +test_print_parse_amount_SOURCES = test-print-parse-amount.cpp
 +
 +GNC_TEST_DEPS = \
 +  --gnc-module-dir ${top_builddir}/libgnucash/engine \
 +  --gnc-module-dir ${top_builddir}/libgnucash/engine/test \
 +  --gnc-module-dir ${top_builddir}/libgnucash/app-utils \
 +  --guile-load-dir ${top_builddir}/libgnucash/core-utils \
 +  --guile-load-dir ${top_builddir}/libgnucash/gnc-module \
 +  --guile-load-dir ${top_builddir}/libgnucash/engine \
 +  --guile-load-dir ${top_builddir}/libgnucash/engine/test \
 +  --guile-load-dir ${top_builddir}/libgnucash/scm \
 +  --guile-load-dir ${top_builddir}/libgnucash/app-utils \
 +  --library-dir    ${top_builddir}/libgnucash/core-utils \
 +  --library-dir    ${top_builddir}/libgnucash/gnc-module \
 +  --library-dir    ${top_builddir}/libgnucash/engine \
 +  --library-dir    ${top_builddir}/libgnucash/backend/xml \
 +  --library-dir    ${top_builddir}/libgnucash/backend/sql \
 +  --library-dir    ${top_builddir}/libgnucash/app-utils
 +
 +TESTS_ENVIRONMENT = \
 +  GUILE_WARN_DEPRECATED=no \
 +  GUILE="${GUILE}" \
 +  SRCDIR=${srcdir} \
 +  GNC_BUILDDIR="${abs_top_builddir}" \
 +  $(shell ${abs_top_srcdir}/common/gnc-test-env.pl --noexports ${GNC_TEST_DEPS})
 +
 +LDADD = \
 +   ${top_builddir}/libgnucash/core-utils/libgnc-core-utils.la \
 +   ${top_builddir}/libgnucash/engine/libgncmod-engine.la \
 +   ${top_builddir}/libgnucash/gnc-module/libgnc-module.la \
 +   ${top_builddir}/libgnucash/app-utils/libgncmod-app-utils.la \
 +   ${top_builddir}/common/test-core/libtest-core.la \
 +   ${top_builddir}/libgnucash/engine/test-core/libgncmod-test-engine.la \
 +   ${GUILE_LIBS}
 +
 +EXTRA_DIST += \
 +  test-print-queries.cpp \
 +  ${SCM_TEST_SRCS} \
 +  CMakeLists.txt
 +
 +AM_CPPFLAGS = \
 +  -I${top_srcdir}/common \
 +  -I${top_srcdir}/common/test-core \
 +  -I${top_srcdir}/libgnucash/engine \
 +  -I${top_srcdir}/libgnucash/engine/test-core \
 +  -I${top_srcdir}/libgnucash/app-utils \
 +  -I${top_srcdir}/libgnucash/gnc-module \
 +  -I${top_srcdir}/libgnucash/core-utils \
 +  ${GUILE_CFLAGS} \
 +  ${GLIB_CFLAGS} \
 +  ${BOOST_CPPFLAGS}
 +
 +test_app_utils_SOURCES = \
 +	test-app-utils.c \
 +	test-option-util.cpp \
 +	test-gnc-ui-util.c
 +
 +test_app_utils_CXXFLAGS = \
 +	${DEFAULT_INCLUDES} \
 +	-I${top_srcdir}/${MODULEPATH}/ \
 +	-DTESTPROG=test_app_utils \
 +	${GLIB_CFLAGS}
 +
- SCM_TESTS =   test-load-app-utils-module test-c-interface
++SCM_TESTS =   test-load-app-utils-module test-c-interface test-date-utilities
 +SCM_TEST_SRCS = $(SCM_TESTS:%=%.scm)
 +
 +$(SCM_TESTS): %: $(srcdir)/%.scm Makefile
 +	echo 'export GNC_BUILDDIR="${abs_top_builddir}";' > $@
 +	echo 'export GNC_UNINSTALLED=yes;' >> $@
 +	echo '${GUILE} --debug -l $(srcdir)/$*.scm -c "(exit (run-test))"' >> $@
 +	chmod a+x $@
diff --cc libgnucash/app-utils/test/test-date-utilities.scm
index 0000000,6fca517..6fca517
mode 000000,100644..100644
--- a/libgnucash/app-utils/test/test-date-utilities.scm
+++ b/libgnucash/app-utils/test/test-date-utilities.scm

commit 82f1384c5827114d44ba51eafabd8ae00590b3aa
Author: John Ralls <jralls at ceridwen.us>
Date:   Sat Dec 23 17:31:18 2017 -0800

    Fix autotools test setup for test-date-utilities.

diff --git a/src/app-utils/test/Makefile.am b/src/app-utils/test/Makefile.am
index b78f046..085089d 100644
--- a/src/app-utils/test/Makefile.am
+++ b/src/app-utils/test/Makefile.am
@@ -4,8 +4,12 @@ TESTS = \
   test-exp-parser \
   test-scm-query-string \
   test-print-parse-amount \
-  test-date-utilities \
-  test-sx
+  test-sx \
+  $(SCM_TESTS)
+
+SCM_TESTS =   test-date-utilities
+
+SCM_TEST_SRCS = $(SCM_TESTS:%=%.scm)
 
 test_exp_parser_SOURCES = \
   test-exp-parser.c
@@ -18,6 +22,7 @@ GNC_TEST_DEPS = --gnc-module-dir ${top_builddir}/src/engine \
   --guile-load-dir ${top_builddir}/src/core-utils \
   --guile-load-dir ${top_builddir}/src/gnc-module \
   --guile-load-dir ${top_builddir}/src/engine \
+  --guile-load-dir ${top_builddir}/src/engine/test \
   --guile-load-dir ${top_builddir}/src/scm \
   --guile-load-dir ${top_builddir}/src/app-utils \
   --library-dir    ${top_builddir}/src/libqof/qof \
@@ -28,6 +33,12 @@ GNC_TEST_DEPS = --gnc-module-dir ${top_builddir}/src/engine \
   --library-dir    ${top_builddir}/src/backend/sql \
   --library-dir    ${top_builddir}/src/app-utils
 
+$(SCM_TESTS): %: $(srcdir)/%.scm Makefile .scm-links
+	echo 'export GNC_BUILDDIR="${abs_top_builddir}";' > $@
+	echo 'export GNC_UNINSTALLED=yes;' >> $@
+	echo '${GUILE} --debug -l $(srcdir)/$*.scm -c "(exit (run-test))"' >> $@
+	chmod a+x $@
+
 TESTS_ENVIRONMENT = \
   GUILE_WARN_DEPRECATED=no \
   GUILE="${GUILE}" \
@@ -68,3 +79,20 @@ AM_CPPFLAGS = \
   -I${top_srcdir}/src/libqof/qof \
   ${GUILE_CFLAGS} \
   ${GLIB_CFLAGS}
+
+.scm-links:
+	$(RM) -rf gnucash
+	mkdir -p  gnucash/app-utils/test
+	( cd gnucash/app-utils/test; for A in $(SCM_TEST_HELPERS) ; do $(LN_S) -f $(abs_srcdir)/$$A . ; done )
+if ! OS_WIN32
+# Windows knows no "ln -s" but uses "cp": must copy every time (see bug #566567).
+	touch .scm-links
+endif
+
+clean-local:
+	$(RM) -rf gnucash
+	$(RM) *.log
+
+noinst_DATA = .scm-links
+CLEANFILES = .scm-links
+DISTCLEANFILES = $(SCM_TESTS)

commit 40654cf50cbc03973d245059f98da0f938fe5ba5
Author: John Ralls <jralls at ceridwen.us>
Date:   Sat Dec 23 17:17:48 2017 -0800

    Fix picky gcc-7.2 complaint about a %d conversion not fitting in 3 bytes.

diff --git a/src/gnome-utils/gnc-dense-cal.c b/src/gnome-utils/gnc-dense-cal.c
index 596a0ae..564ddcd 100644
--- a/src/gnome-utils/gnc-dense-cal.c
+++ b/src/gnome-utils/gnc-dense-cal.c
@@ -1104,7 +1104,7 @@ gnc_dense_cal_draw_to_buffer(GncDenseCal *dcal)
         {
             doc_coords(dcal, doc, &x1, &y1, &x2, &y2);
             memset(dayNumBuf, 0, 3);
-            snprintf(dayNumBuf, 3, "%d", g_date_get_day(&d));
+            snprintf(dayNumBuf, 3, "%hhu", g_date_get_day(&d));
             pango_layout_set_text(layout, dayNumBuf, -1);
             pango_layout_get_pixel_size(layout, &numW, &numH);
             w = (x2 - x1) + 1;

commit 44c51f433b0a07e44d1485cac5c16537031703ba
Author: John Ralls <jralls at ceridwen.us>
Date:   Sat Dec 23 16:42:43 2017 -0800

    Bug 791848 - GC 2.6.x does not handle ISO dates introduced with GC 2.7
    
    Enable reading ISO-formatted dates, recognize GNC_FEATURE_SQLITE3_ISO_DATES.

diff --git a/src/backend/sql/gnc-backend-sql.c b/src/backend/sql/gnc-backend-sql.c
index 7d169d1..76aa181 100644
--- a/src/backend/sql/gnc-backend-sql.c
+++ b/src/backend/sql/gnc-backend-sql.c
@@ -1855,7 +1855,9 @@ typedef Timespec (*TimespecAccessFunc)( const gpointer );
 typedef void (*TimespecSetterFunc)( const gpointer, Timespec );
 
 #define TIMESPEC_STR_FORMAT "%04d%02d%02d%02d%02d%02d"
+#define TIMESPEC_ALT_FORMAT "%04d-%02d%-02d %02d:%02d:%02d"
 #define TIMESPEC_COL_SIZE (4+2+2+2+2+2)
+#define TIMESPEC_ALT_COL_SIZE (4+3+3+3+3+3)
 
 /* This is required because we're passing be->timespace_format to
  * g_strdup_printf.
@@ -1926,22 +1928,24 @@ load_timespec( const GncSqlBackend* be, GncSqlRow* row,
 	else if (G_VALUE_HOLDS_STRING (val))
 	{
             const gchar* s = g_value_get_string( val );
-            if ( s != NULL )
+            if ( s != NULL && strlen(s) == TIMESPEC_COL_SIZE)
+            {
+                gchar* buf;
+                buf = g_strdup_printf( "%c%c%c%c-%c%c-%c%c %c%c:%c%c:%c%c",
+                                       s[0], s[1], s[2], s[3],
+                                       s[4], s[5],
+                                       s[6], s[7],
+                                       s[8], s[9],
+                                       s[10], s[11],
+                                       s[12], s[13] );
+                ts = gnc_iso8601_to_timespec_gmt( buf );
+                g_free( buf );
+                isOK = TRUE;
+            }
+            else if (! g_str_has_prefix (s, "0000-00-00"))
             {
-                 if (! g_str_has_prefix (s, "0000-00-00"))
-                 {
-                      gchar* buf;
-                      buf = g_strdup_printf( "%c%c%c%c-%c%c-%c%c %c%c:%c%c:%c%c",
-                                             s[0], s[1], s[2], s[3],
-                                             s[4], s[5],
-                                             s[6], s[7],
-                                             s[8], s[9],
-                                             s[10], s[11],
-                                             s[12], s[13] );
-                      ts = gnc_iso8601_to_timespec_gmt( buf );
-                      g_free( buf );
-                 }
-                 isOK = TRUE;
+                ts = gnc_iso8601_to_timespec_gmt (s);
+                isOK = TRUE;
             }
         }
         else
diff --git a/src/core-utils/gnc-features.c b/src/core-utils/gnc-features.c
index 1cc495a..03c9418 100644
--- a/src/core-utils/gnc-features.c
+++ b/src/core-utils/gnc-features.c
@@ -46,6 +46,7 @@ static gncFeature known_features[] =
     { GNC_FEATURE_KVP_EXTRA_DATA, "Extra data for addresses, jobs or invoice entries (requires at least GnuCash 2.6.4)" },
     { GNC_FEATURE_GUID_BAYESIAN, "Use account GUID as key for Bayesian data (requires at least GnuCash 2.6.12)" },
     { GNC_FEATURE_GUID_FLAT_BAYESIAN, "Use account GUID as key for bayesian data and store KVP flat (requires at least GnuCash 2.6.19)" },
+    { GNC_FEATURE_SQLITE3_ISO_DATES, "Use ISO formatted date-time strings in SQLite3 databases (requires at least GnuCash 2.6.20)"},
     { NULL },
 };
 
diff --git a/src/core-utils/gnc-features.h b/src/core-utils/gnc-features.h
index a7ed421..df4b590 100644
--- a/src/core-utils/gnc-features.h
+++ b/src/core-utils/gnc-features.h
@@ -46,6 +46,7 @@
 #define GNC_FEATURE_KVP_EXTRA_DATA "Extra data in addresses, jobs or invoice entries"
 #define GNC_FEATURE_GUID_BAYESIAN "Account GUID based Bayesian data"
 #define GNC_FEATURE_GUID_FLAT_BAYESIAN "Account GUID based bayesian with flat KVP"
+#define GNC_FEATURE_SQLITE3_ISO_DATES "ISO-8601 formatted date strings in SQLite3 databases."
 
 /** @} */
 

commit a28bcdf19b1005b2c2937a25e10a21164f741228
Merge: 98fcf1b a847d44
Author: John Ralls <jralls at ceridwen.us>
Date:   Tue Dec 19 22:04:18 2017 -0800

    Merge Chris Lam's Bug 790526 fix into maint.


commit a847d441f14cf66255a8e52f6447b43d9aac447c
Author: christopherlam <christopher.lck at gmail.com>
Date:   Wed Dec 20 11:57:35 2017 +0800

    fix silly mistake

diff --git a/src/app-utils/test/test-date-utilities.scm b/src/app-utils/test/test-date-utilities.scm
index e62610f..6fca517 100644
--- a/src/app-utils/test/test-date-utilities.scm
+++ b/src/app-utils/test/test-date-utilities.scm
@@ -7,12 +7,12 @@
 
 (define (create-time64 l)
   (let ((now (gnc-localtime (current-time))))
-    (set-tm:sec now (list-ref l 0))
-    (set-tm:min now (list-ref l 1))
-    (set-tm:hour now (list-ref l 2))
-    (set-tm:mday now (list-ref l 3))
-    (set-tm:mon now (list-ref l 4))
-    (set-tm:year now (list-ref l 5))
+    (set-tm:sec now (list-ref l 5))
+    (set-tm:min now (list-ref l 4))
+    (set-tm:hour now (list-ref l 3))
+    (set-tm:mday now (list-ref l 2))
+    (set-tm:mon now (list-ref l 1))
+    (set-tm:year now (list-ref l 0))
     (set-tm:isdst now -1)
     (gnc-mktime now)))
 

commit 9af6f184efde5941d09d5d289b6d41a886745a52
Author: christopherlam <christopher.lck at gmail.com>
Date:   Wed Dec 20 10:01:32 2017 +0800

    fix unit test again

diff --git a/src/app-utils/test/test-date-utilities.scm b/src/app-utils/test/test-date-utilities.scm
index 380253a..e62610f 100644
--- a/src/app-utils/test/test-date-utilities.scm
+++ b/src/app-utils/test/test-date-utilities.scm
@@ -16,15 +16,11 @@
     (set-tm:isdst now -1)
     (gnc-mktime now)))
 
-(define (list->time64 l)
-  (create-time64 (list-ref l 0) (list-ref l 1) (list-ref l 2)
-                 (list-ref l 3) (list-ref l 4) (list-ref l 5)))
-
 (define (weeknums-equal? pair-of-dates)
   (let ((d1 (car pair-of-dates))
         (d2 (cdr pair-of-dates)))
-    (equal? (gnc:date-to-week (list->time64 d1))
-            (gnc:date-to-week (list->time64 d2)))))
+    (equal? (gnc:date-to-week (create-time64 d1))
+            (gnc:date-to-week (create-time64 d2)))))
 
 (define (test-weeknum-calculator)
   (and (weeknums-equal? (cons '(1970 1 1 0 0 0)

commit 302d1e73e850b92f5b8076b0af5741fc4afbaa2d
Author: John Ralls <jralls at ceridwen.us>
Date:   Tue Dec 19 17:39:39 2017 -0800

    Add test-date-utilities to CMakeLists.txt and Makefile.am.

diff --git a/src/app-utils/test/CMakeLists.txt b/src/app-utils/test/CMakeLists.txt
index b525b80..dc47478 100644
--- a/src/app-utils/test/CMakeLists.txt
+++ b/src/app-utils/test/CMakeLists.txt
@@ -29,5 +29,7 @@ GNC_ADD_SCHEME_TEST(scm-test-load-module test-load-module.in)
 
 CONFIGURE_FILE(test-load-module.in test-load-module @ONLY)
 
+GNC_ADD_SCHEME_TEST(scm-test-date-utilities test-date-utilities.scm)
+
 SET_DIST_LIST(test_app_utils_DIST CMakeLists.txt Makefile.am test-exp-parser.c test-link-module.c test-load-module.in
-        test-print-parse-amount.c test-print-queries.c test-scm-query-string.c test-sx.c)
\ No newline at end of file
+        test-print-parse-amount.c test-print-queries.c test-scm-query-string.c test-sx.c test-date-utilities.scm)
diff --git a/src/app-utils/test/Makefile.am b/src/app-utils/test/Makefile.am
index 6fb6a95..b78f046 100644
--- a/src/app-utils/test/Makefile.am
+++ b/src/app-utils/test/Makefile.am
@@ -4,6 +4,7 @@ TESTS = \
   test-exp-parser \
   test-scm-query-string \
   test-print-parse-amount \
+  test-date-utilities \
   test-sx
 
 test_exp_parser_SOURCES = \

commit 98fcf1b08efbe4de7a896637d6394aeed8d824c2
Author: John Ralls <jralls at ceridwen.us>
Date:   Tue Dec 19 16:54:01 2017 -0800

    Fix duplicate test-case name.

diff --git a/src/import-export/test/test-flat-bayes.c b/src/import-export/test/test-flat-bayes.c
index 22872ca..b00608b 100644
--- a/src/import-export/test/test-flat-bayes.c
+++ b/src/import-export/test/test-flat-bayes.c
@@ -279,7 +279,7 @@ main (int argc, char *argv[])
     GNC_TEST_ADD (suitename, "guid_bayes_entry", Fixture, NULL, setup, &write_guid_bayes_entry, teardown);
     GNC_TEST_ADD (suitename, "normal_bayes_find", Fixture, NULL, setup, &find_normal_bayes_account, teardown);
     GNC_TEST_ADD (suitename, "guid_bayes_find", Fixture, NULL, setup, &find_guid_bayes_account, teardown);
-    GNC_TEST_ADD (suitename, "normal_bayes_find", Fixture, NULL, setup, &find_normal_bayes_when_non_exists, teardown);
+    GNC_TEST_ADD (suitename, "normal_bayes_find_none", Fixture, NULL, setup, &find_normal_bayes_when_non_exists, teardown);
     GNC_TEST_ADD (suitename, "Mixed case", Fixture, NULL, setup, &group_account_name_and_guid_in_mixed_case, teardown);
     GNC_TEST_ADD (suitename, "Read flat bayes", Fixture, NULL, setup, &read_flat_bayes, teardown);
     GNC_TEST_ADD (suitename, "Write flat bayes", Fixture, NULL, setup, &write_flat_bayes, teardown);

commit 3f408a885bc5d88fbb555a78e019494b7518d69b
Author: christopherlam <christopher.lck at gmail.com>
Date:   Wed Dec 20 08:15:26 2017 +0800

    typo

diff --git a/src/app-utils/test/test-date-utilities.scm b/src/app-utils/test/test-date-utilities.scm
index 393c0f4..380253a 100644
--- a/src/app-utils/test/test-date-utilities.scm
+++ b/src/app-utils/test/test-date-utilities.scm
@@ -5,7 +5,7 @@
 (define (run-test)
   (and (test test-weeknum-calculator)))
 
-(define (create->time64 l)
+(define (create-time64 l)
   (let ((now (gnc-localtime (current-time))))
     (set-tm:sec now (list-ref l 0))
     (set-tm:min now (list-ref l 1))

commit b6ec61fa45c386b641c516782b4501d333a8ea0e
Author: christopherlam <christopher.lck at gmail.com>
Date:   Wed Dec 20 07:58:03 2017 +0800

    add unittest for bugzilla 790526

diff --git a/src/app-utils/test/test-date-utilities.scm b/src/app-utils/test/test-date-utilities.scm
new file mode 100644
index 0000000..393c0f4
--- /dev/null
+++ b/src/app-utils/test/test-date-utilities.scm
@@ -0,0 +1,42 @@
+(use-modules (gnucash gnc-module))
+(gnc:module-begin-syntax (gnc:module-load "gnucash/app-utils" 0))
+(use-modules (gnucash engine test test-extras))
+
+(define (run-test)
+  (and (test test-weeknum-calculator)))
+
+(define (create->time64 l)
+  (let ((now (gnc-localtime (current-time))))
+    (set-tm:sec now (list-ref l 0))
+    (set-tm:min now (list-ref l 1))
+    (set-tm:hour now (list-ref l 2))
+    (set-tm:mday now (list-ref l 3))
+    (set-tm:mon now (list-ref l 4))
+    (set-tm:year now (list-ref l 5))
+    (set-tm:isdst now -1)
+    (gnc-mktime now)))
+
+(define (list->time64 l)
+  (create-time64 (list-ref l 0) (list-ref l 1) (list-ref l 2)
+                 (list-ref l 3) (list-ref l 4) (list-ref l 5)))
+
+(define (weeknums-equal? pair-of-dates)
+  (let ((d1 (car pair-of-dates))
+        (d2 (cdr pair-of-dates)))
+    (equal? (gnc:date-to-week (list->time64 d1))
+            (gnc:date-to-week (list->time64 d2)))))
+
+(define (test-weeknum-calculator)
+  (and (weeknums-equal? (cons '(1970 1 1 0 0 0)
+                              '(1970 1 1 23 59 59)))
+       (weeknums-equal? (cons '(1969 12 31 0 0 0)
+                              '(1969 12 31 23 59 59)))
+       (weeknums-equal? (cons '(1969 12 31 0 0 0)
+                              '(1970 1 1 0 0 1)))
+       (weeknums-equal? (cons '(2001 1 1 0 0 0)
+                              '(2001 1 1 23 59 59)))
+       (not (weeknums-equal? (cons '(1970 1 1 0 0 0)
+                                   '(1970 1 10 0 0 1))))
+       (not (weeknums-equal? (cons '(1969 12 28 0 0 1)
+                                   '(1970 1 5 0 0 1))))
+       ))

commit f3bc8eea8b12b485be698e1501afb168fc20956d
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/src/app-utils/date-utilities.scm b/src/app-utils/date-utilities.scm
index 03faa8f..72eb0f3 100644
--- a/src/app-utils/date-utilities.scm
+++ b/src/app-utils/date-utilities.scm
@@ -198,7 +198,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



Summary of changes:
 CMakeLists.txt                                    |  2 +-
 gnucash/report/report-system/CMakeLists.txt       |  9 ++++--
 libgnucash/app-utils/test/CMakeLists.txt          |  1 +
 libgnucash/app-utils/test/Makefile.am             |  2 +-
 libgnucash/app-utils/test/test-date-utilities.scm | 38 +++++++++++++++++++++++
 libgnucash/engine/test/test-kvp-frame.cpp         |  8 ++---
 6 files changed, 51 insertions(+), 9 deletions(-)
 create mode 100644 libgnucash/app-utils/test/test-date-utilities.scm



More information about the gnucash-changes mailing list