From acb7a2e2071abb8743b04aabf53079ba5733a91c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 24 Mar 2020 22:53:13 +0100 Subject: Add datetime->decimal-hour. --- module/output/html.scm | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'module') diff --git a/module/output/html.scm b/module/output/html.scm index 9f5c7c81..e9b7fd13 100644 --- a/module/output/html.scm +++ b/module/output/html.scm @@ -39,6 +39,17 @@ (/ (minute time) 60) (/ (second time) 3600)))) +(define (datetime->decimal-hour dt) + (unless (and (zero? (month (get-date dt))) + (zero? (year (get-date dt)))) + (error "Multi-month intervals not yet supported" dt)) + ;; TODO + ;; (date-difference #2020-12-31 #2020-01-01) ; => 0000-11-30 + ;; to get number of days in diff-time we need to count number of days + ;; in each month from start and forward + (+ (time->decimal-hour ((@ (datetime) get-time%) dt)) + (* (day (get-date dt)) 24))) + ;; Retuns an HTML-safe version of @var{str}. (define (html-attr str) (define cs (char-set-adjoin char-set:letter+digit #\- #\_)) -- cgit v1.2.3