From 67ce71c11101765f5eb5993a91ea87b47021960e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sun, 26 Apr 2020 01:38:32 +0200 Subject: DTEND now optional for recurrence sets. --- module/vcomponent/recurrence/generate-alt.scm | 44 ++++++++++++++------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/module/vcomponent/recurrence/generate-alt.scm b/module/vcomponent/recurrence/generate-alt.scm index 67dd3981..7337ddaa 100644 --- a/module/vcomponent/recurrence/generate-alt.scm +++ b/module/vcomponent/recurrence/generate-alt.scm @@ -296,12 +296,13 @@ (define duration - ;; NOTE DTEND is an optional field. However, my current configuration for - ;; the parser always adds a DTEND field. + ;; NOTE DTEND is an optional field. (let ((end (attr base-event 'DTEND))) - (if (date? end) - (date-difference end (attr base-event 'DTSTART)) - (datetime-difference end (attr base-event 'DTSTART))))) + (if end + (if (date? end) + (date-difference end (attr base-event 'DTSTART)) + (datetime-difference end (attr base-event 'DTSTART))) + #f))) (define rrule-stream (rrule-instances base-event)) @@ -311,25 +312,26 @@ (aif (hash-ref it dt) it ; RECURRENCE-ID objects come with their own DTEND (let ((ev (copy-vcomponent base-event))) - (set! (attr ev 'DTSTART) dt - ;; p. 123 (3.8.5.3 Recurrence Rule) - ;; specifies that the DTEND should be updated to match how the - ;; initial dtend related to the initial DTSTART. It also notes - ;; that an event of 1 day in length might be longer or shorter - ;; than 24h depending on timezone shifts. - (attr ev 'DTEND) ((cond [(date? dt) date+] - [(datetime? dt) datetime+] - [else (error "Bad type")]) - dt duration)) + (set! (attr ev 'DTSTART) dt) + (when duration + ;; p. 123 (3.8.5.3 Recurrence Rule) + ;; specifies that the DTEND should be updated to match how the + ;; initial dtend related to the initial DTSTART. It also notes + ;; that an event of 1 day in length might be longer or shorter + ;; than 24h depending on timezone shifts. + (set! (attr ev 'DTEND) ((cond [(date? dt) date+] + [(datetime? dt) datetime+] + [else (error "Bad type")]) + dt duration))) ev))) (lambda (dt) (let ((ev (copy-vcomponent base-event))) - (set! (attr ev 'DTSTART) dt - (attr ev 'DTEND) ((cond [(date? dt) date+] - [(datetime? dt) datetime+] - [else (error "Bad type")]) - dt duration) - ) + (set! (attr ev 'DTSTART) dt) + (when duration + (set! (attr ev 'DTEND) ((cond [(date? dt) date+] + [(datetime? dt) datetime+] + [else (error "Bad type")]) + dt duration))) ev))) rrule-stream)) -- cgit v1.2.3