diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-08-17 18:09:46 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-08-17 18:09:46 +0200 |
commit | 051edf0de9f1dd39269b6ecdf1c5e534023dd8e4 (patch) | |
tree | 6a93dc2a7bc3f30d95c567b3f2ff299eef4b5392 /module/output/sxml-types.scm | |
parent | Start moving stuff out from output. (diff) | |
download | calp-051edf0de9f1dd39269b6ecdf1c5e534023dd8e4.tar.gz calp-051edf0de9f1dd39269b6ecdf1c5e534023dd8e4.tar.xz |
Got type files out of output.
Diffstat (limited to 'module/output/sxml-types.scm')
-rw-r--r-- | module/output/sxml-types.scm | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/module/output/sxml-types.scm b/module/output/sxml-types.scm deleted file mode 100644 index 2d5b3742..00000000 --- a/module/output/sxml-types.scm +++ /dev/null @@ -1,55 +0,0 @@ -(define-module (output sxml-types) - :use-module (util) - :use-module (output types) - :use-module (datetime) - :use-module (output common) - ) - -(define (write-boolean _ v) - `(boolean ,(if v "true" "false"))) - -(define (write-date _ v) - `(date ,(date->string v "~Y-~m-~d"))) - -(define (write-datetime p v) - `(date-time - ,(datetime->string - (hashq-ref p '-X-HNH-ORIGINAL v) - ;; 'Z' should be included for UTC, - ;; other timezones MUST be specified - ;; in the TZID parameter. - "~Y-~m-~dT~H:~M:~S~Z"))) - -(define (write-time _ v) - `(time ,(time->string v "~H:~M:S"))) - -(define (write-recur _ v) - `(recur ,@((@@ (vcomponent recurrence internal) recur-rule->rrule-sxml) v))) - -;; sepparate since this text shouldn't be escaped -(define (write-text _ v) - ;; TODO out type should be xsd:string. - ;; Look into what that means, and escape - ;; from there - `(text ,v)) - - - -(define sxml-writers (make-hash-table)) -(for simple-type in '(BINARY DURATION CAL-ADDRESS DURATION FLOAT INTEGER - #| TODO PERIOD |# URI UTC-OFFSET) - (hashq-set! sxml-writers simple-type - (lambda (p v) - `(,(downcase-symbol simple-type) - ,(((@ (output types) get-writer) simple-type) p v))))) - -(hashq-set! sxml-writers 'BOOLEAN write-boolean) -(hashq-set! sxml-writers 'DATE write-date) -(hashq-set! sxml-writers 'DATE-TIME write-datetime) -(hashq-set! sxml-writers 'TIME write-time) -(hashq-set! sxml-writers 'RECUR write-recur) -(hashq-set! sxml-writers 'TEXT write-text) - -(define-public (get-writer type) - (or (hashq-ref sxml-writers type #f) - (error "No writer for type" type))) |