aboutsummaryrefslogtreecommitdiff
path: root/module/srfi
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@hornquist.se>2020-02-11 22:16:36 +0100
committerHugo Hörnquist <hugo@hornquist.se>2020-02-11 22:16:36 +0100
commitfddc0373388f1468f99f60ae57278325c5dcea0d (patch)
tree47038e07bec4746a507cc52b621cd51895695aa4 /module/srfi
parentAdd tests for time<. (diff)
downloadcalp-fddc0373388f1468f99f60ae57278325c5dcea0d.tar.gz
calp-fddc0373388f1468f99f60ae57278325c5dcea0d.tar.xz
Hopefully fixed date+ bugs.
Diffstat (limited to 'module/srfi')
-rw-r--r--module/srfi/srfi-19/alt.scm13
1 files changed, 8 insertions, 5 deletions
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