aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@hornquist.se>2019-04-24 01:08:06 +0200
committerHugo Hörnquist <hugo@hornquist.se>2019-04-24 01:08:06 +0200
commitd26d16dc7d70077d47089756fb30fe4b6e3808d4 (patch)
tree76e98d857fbd8d355580bde4858a985433ad7c36
parentImprove text layout code. (diff)
downloadcalp-d26d16dc7d70077d47089756fb30fe4b6e3808d4.tar.gz
calp-d26d16dc7d70077d47089756fb30fe4b6e3808d4.tar.xz
Add 'from' and 'to' flags to HTML.
-rw-r--r--module/output/html.scm19
-rw-r--r--module/output/terminal.scm3
-rw-r--r--module/srfi/srfi-19/util.scm6
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 (time<? a b) b a))
+
+
+;; TODO possibly put this in some form of parser module.
+;; TODO actually allow many form date form.
+(define-public (parse-freeform-date str)
+ (string->date str "~Y-~m-~d"))