From 7eba3f7dbcef5ecf05d6d05e1c2fbd323d7898df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sat, 9 Feb 2019 03:01:53 +0100 Subject: Add some more scheme bindings. --- code.scm | 51 ++++++++++++++++++++++----------------------------- 1 file changed, 22 insertions(+), 29 deletions(-) (limited to 'code.scm') diff --git a/code.scm b/code.scm index aef2772b..2c598c46 100755 --- a/code.scm +++ b/code.scm @@ -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") -;; => # - -;; (string->date (calendar-get-attr v 0 "dtstart") -;; "~Y~m~eT~k~M~S") -;; => # - -;; (string-take-right (calendar-get-attr v 0 "dtstart") 1) ; => "Z" - -;; (string->date "20180311T133700" -;; "~Y~m~eT~k~M~S") ; <-- Note missing ~z -;; => # -- cgit v1.2.3