diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-06-25 22:35:48 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-06-25 22:35:48 +0200 |
commit | b9ce4240a4d729b051acab17896f4102e0fbf123 (patch) | |
tree | c0d5ca30f5563a2302a7b055b46e084c60e50787 /module/output/common.scm | |
parent | Add minor todo. (diff) | |
download | calp-b9ce4240a4d729b051acab17896f4102e0fbf123.tar.gz calp-b9ce4240a4d729b051acab17896f4102e0fbf123.tar.xz |
Move stuff from output/ical to output/common./
Diffstat (limited to 'module/output/common.scm')
-rw-r--r-- | module/output/common.scm | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/module/output/common.scm b/module/output/common.scm new file mode 100644 index 00000000..c501bcae --- /dev/null +++ b/module/output/common.scm @@ -0,0 +1,42 @@ +;;; Commentary: +;; Common code between all serializers. +;; (ical and xcal). Not for graphical output stuff. +;;; Code: + +(define-module (output common) + :use-module (util) + ) + +;; TODO this is also defined @ (vcomponent parse component) +(define-public (x-property? symb) + (string=? "X-" (string-take (symbol->string symb) 2))) + +;; TODO this is also defined twice +(define (generate-uuid) + ((@ (rnrs io ports) call-with-port) + ((@ (ice-9 popen) open-input-pipe) "uuidgen") + (@ (ice-9 rdelim) read-line))) + +(define*-public (internal-field? symbol optional: (prefix "X-HNH-")) + (string=? prefix + (string-take-to (symbol->string symbol) + (string-length prefix)))) + +(define-public (->string a) + (with-output-to-string (lambda () (display a)))) + +(define-public (get-tz-names events) + (lset-difference + equal? (lset-union + equal? '("dummy") + (filter-map + (lambda (vline) (and=> (prop vline 'TZID) car)) + (filter-map (extract* 'DTSTART) + events))) + '("dummy" "local"))) + +(define-public (downcase-symbol symb) + (-> symb + symbol->string + string-downcase + string->symbol)) |