diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-03-24 22:53:13 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-03-24 22:53:13 +0100 |
commit | acb7a2e2071abb8743b04aabf53079ba5733a91c (patch) | |
tree | f3fde6342859db2e7efb0f64645c962744936827 /module | |
parent | Change date{,time}-difference to hopefully sensible types. (diff) | |
download | calp-acb7a2e2071abb8743b04aabf53079ba5733a91c.tar.gz calp-acb7a2e2071abb8743b04aabf53079ba5733a91c.tar.xz |
Add datetime->decimal-hour.
Diffstat (limited to 'module')
-rw-r--r-- | module/output/html.scm | 11 |
1 files changed, 11 insertions, 0 deletions
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 #\- #\_)) |