aboutsummaryrefslogtreecommitdiff
path: root/module/vcomponent/parse
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-05-09 22:04:30 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-05-09 22:04:30 +0200
commit3b8ef9b49a2ecc39ab209a67dfaac05e86c192ab (patch)
tree55ec420ca94d435701fd780b9379edf79be6dae8 /module/vcomponent/parse
parentNew parser now on feature parity with old. (diff)
downloadcalp-3b8ef9b49a2ecc39ab209a67dfaac05e86c192ab.tar.gz
calp-3b8ef9b49a2ecc39ab209a67dfaac05e86c192ab.tar.xz
Minor cleanup.
Diffstat (limited to 'module/vcomponent/parse')
-rw-r--r--module/vcomponent/parse/new.scm28
1 files changed, 5 insertions, 23 deletions
diff --git a/module/vcomponent/parse/new.scm b/module/vcomponent/parse/new.scm
index 90614820..4244725a 100644
--- a/module/vcomponent/parse/new.scm
+++ b/module/vcomponent/parse/new.scm
@@ -6,16 +6,10 @@
:use-module (datetime)
:use-module (srfi srfi-1)
:use-module (srfi srfi-26)
- :use-module ((ice-9 hash-table) :select (alist->hashq-table))
)
(define-public (parse-calendar port)
- (let ((component (parse (map tokenize (read-file port)))))
- ;; (set! (attr component 'X-HNH-FILENAME) (or (port-filename port) "MISSING"))
- component))
-
-
-;; (define f (open-input-file (car (glob "~/.local/var/cal/Calendar/c17*"))))
+ (parse (map tokenize (read-file port))))
;; port → (list string)
(define (read-file port)
@@ -56,13 +50,10 @@
(let ((type (hashq-ref params 'VALUE)))
(if (or (and=> type (cut string=? <> "DATE-TIME"))
(string-index value #\T))
- ;; TODO TODO TODO
;; we move all parsed datetimes to local time here. This
;; gives a MASSIVE performance boost over calling get-datetime
;; in all procedures which want to guarantee local time for proper calculations.
;; 20s vs 70s runtime on my laptop.
- ;; We sohuld however save the original datetime in a file like X-HNH-DTSTART,
- ;; since we don't want to lose that information.
(let ((datetime (parse-ics-datetime value tz)))
(hashq-set! params 'VALUE 'DATE-TIME)
(values (make-vline key (get-datetime datetime) params)
@@ -85,12 +76,10 @@
(cons (car rem) (loop (cdr rem)))))))
params)]))
-;; (parse-itemline '("DTEND" "TZID=Europe/Stockholm" "VALUE=DATE-TIME" "20200407T130000"))
-;; => (DTEND "20200407T130000" #<hash-table 7f88fb094d80 2/31>)
;; (parse-itemline '("DTEND" "20200407T130000"))
-;; => (DTEND "20200407T130000" #<hash-table 7f88facafd20 0/31>)
-;; ⇒ (DTEND . #<<vline> value: #<<datetime> date: 2020-04-07 time: 13:00:00 tz: #f>
-;; parameters: #<hash-table 7f88fc1207a0 2/31>>
+;; => DTEND
+;; => "20200407T130000"
+;; => #<hash-table 7f76b5f82a60 0/31>
(define (parse-itemline itemline)
(define key (string->symbol (car itemline)))
(define parameters (make-hash-table))
@@ -134,10 +123,8 @@
(if (null? (cdr stack))
;; return
(car stack)
- ;; TODO link parent here?
(begin (add-child! (cadr stack) (car stack))
- (cdr stack))
- ))]
+ (cdr stack))))]
[else
(let* ((key value params (parse-itemline head)))
(call-with-values (lambda () (build-vline key value params))
@@ -154,8 +141,3 @@
(set! (attr* (car stack) key) vline))))))
(loop (cdr lst) stack)])))))
-
-
-
-
-;; Repeated keys ('(EXDATE ATTENDEE))