gnucash maint: Multiple changes pushed
John Ralls
jralls at code.gnucash.org
Wed Dec 20 01:05:30 EST 2017
Updated 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/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/98fcf1b0 (commit)
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 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:
src/app-utils/date-utilities.scm | 2 +-
src/app-utils/test/CMakeLists.txt | 4 +++-
src/app-utils/test/Makefile.am | 1 +
src/app-utils/test/test-date-utilities.scm | 38 ++++++++++++++++++++++++++++++
4 files changed, 43 insertions(+), 2 deletions(-)
create mode 100644 src/app-utils/test/test-date-utilities.scm
More information about the gnucash-changes
mailing list