aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@hornquist.se>2019-04-23 17:22:19 +0200
committerHugo Hörnquist <hugo@hornquist.se>2019-04-23 17:24:27 +0200
commite3556cfa008a7a2df2ada035ee25a3035e961558 (patch)
tree73a4f792031c9797acd75b2557ea0397b57c31bf
parentAdd time-{min,max}. (diff)
downloadcalp-e3556cfa008a7a2df2ada035ee25a3035e961558.tar.gz
calp-e3556cfa008a7a2df2ada035ee25a3035e961558.tar.xz
Add event-length/day.
-rw-r--r--module/vcalendar/datetime.scm7
1 files changed, 7 insertions, 0 deletions
diff --git a/module/vcalendar/datetime.scm b/module/vcalendar/datetime.scm
index 2715b5db..1e5b5853 100644
--- a/module/vcalendar/datetime.scm
+++ b/module/vcalendar/datetime.scm
@@ -49,3 +49,10 @@ Event must have the DTSTART and DTEND attribute set."
(time-difference
(attr e 'DTEND)
(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}.
+(define-public (event-length/day e start-of-day)
+ (time-difference
+ (time-min (add-day start-of-day) (attr e 'DTEND))
+ (time-max start-of-day (attr e 'DTSTART))))