aboutsummaryrefslogtreecommitdiff
path: root/code.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@hornquist.se>2019-02-26 01:25:54 +0100
committerHugo Hörnquist <hugo@hornquist.se>2019-02-26 01:25:54 +0100
commitd509f3479d9c94831090ddc0049d14c7bdb2bae7 (patch)
treed5d33d43f8fad2dfbf3cb2c7ea63a73419200912 /code.scm
parentRemove printing of all opened filenames. (diff)
downloadcalp-d509f3479d9c94831090ddc0049d14c7bdb2bae7.tar.gz
calp-d509f3479d9c94831090ddc0049d14c7bdb2bae7.tar.xz
Add simple sorted agenda to code.scm.
Diffstat (limited to 'code.scm')
-rwxr-xr-xcode.scm25
1 files changed, 18 insertions, 7 deletions
diff --git a/code.scm b/code.scm
index 4de59236..44444c3a 100755
--- a/code.scm
+++ b/code.scm
@@ -7,15 +7,26 @@
(srfi srfi-26)
(vcalendar))
-(define cal (make-vcomponent "testcal/d1-b.ics"))
+(define path
+ (if (null? (cdr (command-line)))
+ "testcal/d1-b.ics"
+ (cadr (command-line))))
+(define cal (make-vcomponent path))
+
+;;; Parse all start times into scheme date objects.
(for-each (cut transform-attr! <> "DTSTART"
(cut string->date <> "~Y~m~dT~H~M~S"))
(children cal))
-(display (get-attr (car (children cal))
- "DTSTART"))
-(newline)
-(display (get-attr (car (children cal))
- "DTSTART"))
-(newline)
+;;; Sort the events, and print a simple agenda.
+(let ((sorted-events
+ (sort (children cal)
+ (lambda (a b)
+ (time<? (date->time-utc (get-attr a "DTSTART"))
+ (date->time-utc (get-attr b "DTSTART")))))))
+ (for-each (lambda (ev) (format #t "~a | ~a~%"
+ (date->string (get-attr ev "DTSTART") "~1 ~H:~M")
+ (get-attr ev "SUMMARY")))
+ sorted-events))
+