From 6682ea207191419dbbf3a2849d8519c52ac5860a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sat, 9 May 2020 13:31:23 +0200 Subject: New parser now works with old code. A DTEND filed is added as before. One of the EXDATE fields is saves as a list, the remaining are however thrown away. --- module/vcomponent/parse/new.scm | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'module/vcomponent/parse') diff --git a/module/vcomponent/parse/new.scm b/module/vcomponent/parse/new.scm index e87ed020..9c97a7c8 100644 --- a/module/vcomponent/parse/new.scm +++ b/module/vcomponent/parse/new.scm @@ -83,7 +83,11 @@ (set! (value vline) (get-datetime (parse-ics-datetime (value vline) tz)) (prop vline 'VALUE) 'DATE-TIME) (set! (value vline) (parse-ics-date (value vline)) - (prop vline 'VALUE) 'DATE))))]) + (prop vline 'VALUE) 'DATE))) + ;; TOOD actually handle repeated keys + (when (eq? key 'EXDATE) + (set! (value vline) (list (value vline)))) + )]) vline) ;; (parse-itemline '("DTEND" "TZID=Europe/Stockholm" "VALUE=DATE-TIME" "20200407T130000")) @@ -108,8 +112,24 @@ (define (make-component type . children-and-attributes) - (let* ((children attributes (partition vcomponent? children-and-attributes))) - ((@@ (vcomponent base) make-vcomponent%) type children #f (alist->hashq-table attributes)))) + (define component + (let* ((children attributes (partition vcomponent? children-and-attributes))) + ((@@ (vcomponent base) make-vcomponent%) type children #f (alist->hashq-table attributes)))) + + ;; TODO This is an ugly hack until the rest of the code is updated + ;; to work on events without an explicit DTEND attribute. + (when (and (eq? type 'VEVENT) (not (attr component 'DTEND))) + (set! (attr component 'DTEND) + (let ((start (attr component 'DTSTART))) + ;; p. 54, 3.6.1 + ;; If DTSTART is a date then it's an all + ;; day event. If DTSTART instead is a + ;; datetime then the event has a length + ;; of 0? + (if (date? start) + (date+ start (date day: 1)) + (datetime+ start (datetime time: (time hour: 1))))))) + component) ;; (list (key kv ... value)) → (define (parse lst) @@ -141,5 +161,4 @@ -;; DTEND when missing in VEVENT ;; Repeated keys ('(EXDATE ATTENDEE)) -- cgit v1.2.3