From 3b8ef9b49a2ecc39ab209a67dfaac05e86c192ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sat, 9 May 2020 22:04:30 +0200 Subject: Minor cleanup. --- module/vcomponent/parse/new.scm | 28 +++++----------------------- 1 file 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" #) ;; (parse-itemline '("DTEND" "20200407T130000")) -;; => (DTEND "20200407T130000" #) -;; ⇒ (DTEND . #< value: #< date: 2020-04-07 time: 13:00:00 tz: #f> -;; parameters: #> +;; => DTEND +;; => "20200407T130000" +;; => # (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)) -- cgit v1.2.3