From fddc0373388f1468f99f60ae57278325c5dcea0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 11 Feb 2020 22:16:36 +0100 Subject: Hopefully fixed date+ bugs. --- module/srfi/srfi-19/alt.scm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'module') diff --git a/module/srfi/srfi-19/alt.scm b/module/srfi/srfi-19/alt.scm index 9fe3f9d2..82a16627 100644 --- a/module/srfi/srfi-19/alt.scm +++ b/module/srfi/srfi-19/alt.scm @@ -296,14 +296,17 @@ (values days-fixed change*) (let loop ((target days-fixed) (change change*)) ;; (format (current-error-port) "2 ~s : ~s~%" target change) - (if (>= 12 (+ (month change) (month target))) - (values (set (month target) = (+ (month change))) - (set (month change) 0)) - + (if (< 12 (+ (month change) (month target))) + ;; if we overflow into the next year (loop (set-> target (year = (+ 1)) (month 1)) - (set (month change) = (- 12 (month target)))) + (set (month change) = (- (- 13 (month target))))) + + ;; if we don't overflow our date + (values (set (month target) = (+ (month change))) + (set (month change) 0)) + )))) ;; change** should here should have both month and date = 0 -- cgit v1.2.3