aboutsummaryrefslogtreecommitdiff
path: root/module/vcomponent/datetime.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-03-24 22:52:57 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2020-03-24 22:52:57 +0100
commite7c99e14691e768e0c3e7c54049301183ddfc32f (patch)
treed71df8a65506c6ab5c935e7ed2e25a0fd9ce5d13 /module/vcomponent/datetime.scm
parentAdd date-{min,max}. (diff)
downloadcalp-e7c99e14691e768e0c3e7c54049301183ddfc32f.tar.gz
calp-e7c99e14691e768e0c3e7c54049301183ddfc32f.tar.xz
Change date{,time}-difference to hopefully sensible types.
Diffstat (limited to 'module/vcomponent/datetime.scm')
-rw-r--r--module/vcomponent/datetime.scm16
1 files changed, 12 insertions, 4 deletions
diff --git a/module/vcomponent/datetime.scm b/module/vcomponent/datetime.scm
index 4db9dbf1..5df4dfab 100644
--- a/module/vcomponent/datetime.scm
+++ b/module/vcomponent/datetime.scm
@@ -51,12 +51,20 @@ Event must have the DTSTART and DTEND attribute set."
(if (date? (attr e 'DTSTART))
#24:00:00
#01:00:00))
- (datetime-difference (as-datetime (attr e 'DTEND))
- (as-datetime (attr e 'DTSTART)))))
+ ((if (date? (attr e 'DTSTART))
+ date-difference datetime-difference)
+ (attr e 'DTEND) (attr e 'DTSTART))))
(define-public (event-length/clamped start-date end-date e)
- (datetime-difference (datetime-min (datetime date: (date+ end-date (date day: 1))) (as-datetime (attr e 'DTEND)))
- (datetime-max (datetime date: start-date) (as-datetime (attr e 'DTSTART)))))
+ (if (date? (attr e 'DTSTART))
+ (date-difference (date-min (date+ end-date (date day: 1))
+ (attr e 'DTEND))
+ (date-max start-date
+ (attr e 'DTSTART)))
+ (datetime-difference (datetime-min (datetime date: (date+ end-date (date day: 1)))
+ (get-datetime (attr e 'DTEND)))
+ (datetime-max (datetime date: start-date)
+ (get-datetime (attr e 'DTSTART))))))
;; Returns the length of the part of @var{e} which is within the day
;; starting at the time @var{start-of-day}.