diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2019-02-09 03:01:53 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2019-02-09 03:01:53 +0100 |
commit | 7eba3f7dbcef5ecf05d6d05e1c2fbd323d7898df (patch) | |
tree | 3ba6b44d20b9f857207e55487154e8d378caea90 /code.scm | |
parent | Add support for full tree printing. (diff) | |
download | calp-7eba3f7dbcef5ecf05d6d05e1c2fbd323d7898df.tar.gz calp-7eba3f7dbcef5ecf05d6d05e1c2fbd323d7898df.tar.xz |
Add some more scheme bindings.
Diffstat (limited to 'code.scm')
-rwxr-xr-x | code.scm | 51 |
1 files changed, 22 insertions, 29 deletions
@@ -2,43 +2,36 @@ -s !# -(use-modules (ice-9 format)) +(add-to-load-path (dirname (current-filename))) +(load "helpers.scm") + +(use-modules (ice-9 format) + (ice-9 pretty-print)) (begin ;; Supurflous begin block here to make sourcing into geiser easier. (setenv "LD_LIBRARY_PATH" (getcwd)) (load-extension "libguile-calendar" "init_calendar")) -(define v (make-calendar (cadr (command-line)))) - +(define (get-properties calendar) + "Fancy wrappen around primitive-get-properties. +Transforms character codes into actuall chcaracters." + (define (recur tree) + (let ((head (car tree))) + (cons (cons (integer->char (car head)) + (cdr head)) + (map recur (cdr tree))))) + (let ((result (recur (primitive-get-properties calendar)))) + (cons 'ROOT (cdr result)))) + +(let* ((v (make-calendar "test-cal/alarm")) + (props (get-properties (cadr (get-components (car (get-components v))))))) + (pretty-print (beautify (flatten props))) + (newline)) + +#; (do ((i 0 (1+ i))) ((>= i (calendar-size v))) (format #t "~3d | ~a~%" (1+ i) (car (calendar-get-attr v i "summary")))) - -;;; ---------------------------------------- - -;; (use-modules (srfi srfi-19)) - -#| -- Z at end means that it's in UTC time. -- No mark at end means that it's in "local time". -- `TZID` can be given as an parameter, specifiying the timezone by name - -See p. 46-47 of the RFC -|# - -;; (string->date (calendar-get-attr v 0 "dtstart") -;; "~Y~m~eT~k~M~S~z") -;; => #<date nanosecond: 0 second: 0 minute: 15 hour: 12 day: 29 month: 1 year: 2019 zone-offset: 0> - -;; (string->date (calendar-get-attr v 0 "dtstart") -;; "~Y~m~eT~k~M~S") -;; => #<date nanosecond: 0 second: 0 minute: 15 hour: 12 day: 29 month: 1 year: 2019 zone-offset: 3600> - -;; (string-take-right (calendar-get-attr v 0 "dtstart") 1) ; => "Z" - -;; (string->date "20180311T133700" -;; "~Y~m~eT~k~M~S") ; <-- Note missing ~z -;; => #<date nanosecond: 0 second: 0 minute: 37 hour: 13 day: 11 month: 3 year: 2018 zone-offset: 3600> |