aboutsummaryrefslogtreecommitdiff
path: root/module
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-03-25 14:04:51 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2019-03-25 14:04:51 +0100
commitd1a70bb80f24e51152aa3dd0bdca621396975bd4 (patch)
tree3e4f3a6567fab60a6d0f097de8ddc31e68258323 /module
parentMinor cleanups. (diff)
downloadcalp-d1a70bb80f24e51152aa3dd0bdca621396975bd4.tar.gz
calp-d1a70bb80f24e51152aa3dd0bdca621396975bd4.tar.xz
Fix timespan-overlaps? to align better with days.
Diffstat (limited to 'module')
-rw-r--r--module/srfi/srfi-19/util.scm37
1 files changed, 20 insertions, 17 deletions
diff --git a/module/srfi/srfi-19/util.scm b/module/srfi/srfi-19/util.scm
index f589b988..3126be77 100644
--- a/module/srfi/srfi-19/util.scm
+++ b/module/srfi/srfi-19/util.scm
@@ -53,34 +53,37 @@ attribute set to 0. Can also be seen as \"Start of day\""
(define* (time->string time #:optional (format "~1 ~3"))
(date->string (time-utc->date time) format))
-
(define (add-day time)
- (add-duration time (make-time time-duration 0 (* 60 60 24))))
+ (add-duration time (make-duration (* 60 60 24))))
(define (remove-day time)
- (add-duration time (make-time time-duration 0 (- (* 60 60 24)))))
+ (add-duration time (make-duration (- (* 60 60 24)))))
-;; A B C D ¬E
-;; |s1| : |s2| : |s1| : |s2| : |s1|
-;; | | : | | : | ||s2| : |s1|| | : | |
-;; | ||s2| : |s1|| | : | || | : | || | :
-;; | | : | | : | || | : | || | : |s2|
-;; | | : | | : | | : | | : | |
+;; @verbatim
+;; A B C D E ¬F
+;; |s1| : |s2| : |s1| : |s2| : : |s1|
+;; | | : | | : | ||s2| : |s1|| | : |s1||s2| : | |
+;; | ||s2| : |s1|| | : | || | : | || | : | || | :
+;; | | : | | : | || | : | || | : | || | : |s2|
+;; | | : | | : | | : | | : : | |
+;; @end verbatim
+;;
+;; E is covered by both case A and B.
(define-public (timespan-overlaps? s1-begin s1-end s2-begin s2-end)
"Return whetever or not two timespans overlap."
(or
;; A
- (and (time<=? s2-begin s1-end)
- (time<=? s1-begin s2-end))
+ (and (time<? s2-begin s1-end)
+ (time<? s1-begin s2-end))
;; B
- (and (time<=? s1-begin s2-end)
- (time<=? s2-begin s1-end))
+ (and (time<? s1-begin s2-end)
+ (time<? s2-begin s1-end))
;; C
- (and (time<=? s1-begin s2-begin)
- (time<=? s2-end s1-end))
+ (and (time<? s1-begin s2-begin)
+ (time<? s2-end s1-end))
;; D
- (and (time<=? s2-begin s1-begin)
- (time<=? s1-end s2-end))))
+ (and (time<? s2-begin s1-begin)
+ (time<? s1-end s2-end))))