From d26d16dc7d70077d47089756fb30fe4b6e3808d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Wed, 24 Apr 2019 01:08:06 +0200 Subject: Add 'from' and 'to' flags to HTML. --- module/output/html.scm | 19 +++++++++++++------ module/output/terminal.scm | 3 --- module/srfi/srfi-19/util.scm | 6 ++++++ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/module/output/html.scm b/module/output/html.scm index 614fc1cb..a58fce0c 100644 --- a/module/output/html.scm +++ b/module/output/html.scm @@ -10,6 +10,8 @@ #:use-module (srfi srfi-19 util) #:use-module (output general) + #:use-module (ice-9 getopt-long) + #:use-module (parameters) #:use-module (config)) @@ -114,21 +116,26 @@ ,(string-append time ":00"))) (map number->string (iota 12 0 2)))) -(define (d str) - (string->date str "~Y-~m-~d")) - (define (include-css path) `(link (@ (type "text/css") (rel "stylesheet") (href ,path)))) +(define opt-spec + '((from (value #t) (single-char #\f)) + (to (value #t) (single-char #\t)))) + (define-public (html-main calendars events args) + (define opts (getopt-long args opt-spec)) + + (define start (parse-freeform-date (option-ref opts 'from "2019-04-15"))) + (define end (parse-freeform-date (option-ref opts 'to "2019-05-10"))) + (define evs (filter-sorted-stream - (compose (in-date-range? - (d "2019-04-15") - (d "2019-05-10")) + ;; TODO in-date-range? drops the first date + (compose (in-date-range? start end) car) (group-stream events))) diff --git a/module/output/terminal.scm b/module/output/terminal.scm index 92e93cc8..bbe7f041 100644 --- a/module/output/terminal.scm +++ b/module/output/terminal.scm @@ -123,9 +123,6 @@ (define options '((date (value #t) (single-char #\d)))) -(define (parse-freeform-date str) - (string->date str "~Y-~m-~d")) - (define (terminal-main calendars events args) (let ((opts (getopt-long args options))) (let ((time (date->time-utc diff --git a/module/srfi/srfi-19/util.scm b/module/srfi/srfi-19/util.scm index e4014a68..ea8e2f7f 100644 --- a/module/srfi/srfi-19/util.scm +++ b/module/srfi/srfi-19/util.scm @@ -117,3 +117,9 @@ attribute set to 0. Can also be seen as \"Start of day\"" (define-public (time-max a b) (if (timedate str "~Y-~m-~d")) -- cgit v1.2.3