From b9ce4240a4d729b051acab17896f4102e0fbf123 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Thu, 25 Jun 2020 22:35:48 +0200 Subject: Move stuff from output/ical to output/common./ --- module/output/common.scm | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 module/output/common.scm (limited to 'module/output/common.scm') 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)) -- cgit v1.2.3