aboutsummaryrefslogtreecommitdiff
path: root/module/vcomponent/parse
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-05-09 13:31:23 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-05-09 13:31:41 +0200
commit6682ea207191419dbbf3a2849d8519c52ac5860a (patch)
treec9fd0584ea527d391c830103dd3ff916fd275521 /module/vcomponent/parse
parentWork on new parser, almost works. (diff)
downloadcalp-6682ea207191419dbbf3a2849d8519c52ac5860a.tar.gz
calp-6682ea207191419dbbf3a2849d8519c52ac5860a.tar.xz
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.
Diffstat (limited to 'module/vcomponent/parse')
-rw-r--r--module/vcomponent/parse/new.scm27
1 files changed, 23 insertions, 4 deletions
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)) → <vcomponent>
(define (parse lst)
@@ -141,5 +161,4 @@
-;; DTEND when missing in VEVENT
;; Repeated keys ('(EXDATE ATTENDEE))