aboutsummaryrefslogtreecommitdiff
path: root/module/vcomponent/recurrence
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@hornquist.se>2019-12-23 02:17:59 +0100
committerHugo Hörnquist <hugo@hornquist.se>2019-12-23 11:06:30 +0100
commit7f6eebf37ac9310cfa5de4a33963b997bb873299 (patch)
treecf02b7211f012d5ab131869410c6672cff336634 /module/vcomponent/recurrence
parentAdd awhen. (diff)
downloadcalp-7f6eebf37ac9310cfa5de4a33963b997bb873299.tar.gz
calp-7f6eebf37ac9310cfa5de4a33963b997bb873299.tar.xz
Fix reccuring events with exceptions.
An event with an RRULE can have extra VEVENT's which share their UID, but add a RECCURENCE-ID which contains when the event was supposed to take place. In place of that time it may supply it's own overriding time. It may also override other fields.
Diffstat (limited to 'module/vcomponent/recurrence')
-rw-r--r--module/vcomponent/recurrence/generate.scm16
1 files changed, 15 insertions, 1 deletions
diff --git a/module/vcomponent/recurrence/generate.scm b/module/vcomponent/recurrence/generate.scm
index 84025d2f..0ad30c84 100644
--- a/module/vcomponent/recurrence/generate.scm
+++ b/module/vcomponent/recurrence/generate.scm
@@ -1,4 +1,5 @@
(define-module (vcomponent recurrence generate)
+ #:use-module ((srfi srfi-1) :select (find))
#:use-module (srfi srfi-19) ; Datetime
#:use-module (srfi srfi-19 util)
#:use-module (srfi srfi-19 setters)
@@ -85,7 +86,20 @@
(stream-unfold
;; Event x Rule → Event
- car
+ (match-lambda
+ ((e _)
+ (let ((expected-start (attr e 'DTSTART)))
+ ;; If we have alternatives, check them
+ (cond [(attr e 'X-HNH-ALTERNATIVES)
+ (lambda (alternatives)
+ ;; A recurrence id matching the expected time means that
+ ;; we have an actuall alternative/exception, use that
+ ;; instead of the regular event.
+ (find (lambda (alt) (time=? expected-start (attr alt 'RECURRENCE-ID)))
+ alternatives))
+ => identity]
+ ;; If we did't have an exception just return the regular event.
+ [else e]))))
;; Event x Rule → Bool (continue?)
(match-lambda