From 7f6eebf37ac9310cfa5de4a33963b997bb873299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 23 Dec 2019 02:17:59 +0100 Subject: 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. --- module/vcomponent/recurrence/generate.scm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'module/vcomponent/recurrence') 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 -- cgit v1.2.3