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.
This commit is contained in:
Christopher Lam
2017-12-19 23:10:29 +08:00
parent 7550ccf537
commit d41ad85f0a

View File

@@ -566,9 +566,20 @@
(or
(and (eq? 'relative (car date)) (symbol? (cdr date)))
(and (eq? 'absolute (car date))
(pair? (cdr date))
(exact? (cadr date))
(exact? (cddr 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)