aboutsummaryrefslogtreecommitdiff
path: root/module
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-03-02 00:41:09 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2020-03-02 00:41:15 +0100
commit4c711fa527117743a151ae2584095948e89bdc34 (patch)
treea80acd17768b43591055abaa38672e6144ad1821 /module
parentMade start of week for html configurable. (diff)
downloadcalp-4c711fa527117743a151ae2584095948e89bdc34.tar.gz
calp-4c711fa527117743a151ae2584095948e89bdc34.tar.xz
Made cal-table simpler.
Diffstat (limited to 'module')
-rw-r--r--module/output/html.scm50
1 files changed, 28 insertions, 22 deletions
diff --git a/module/output/html.scm b/module/output/html.scm
index faac4c92..f4751b03 100644
--- a/module/output/html.scm
+++ b/module/output/html.scm
@@ -256,31 +256,37 @@
`(table (@ (class "small-calendar"))
;; NOTE Sunday first since my code assumes that is the first day of the week.
(thead (tr ,@(map (lambda (d) `(td ,(week-day-name d 2)))
- ; '(SÖ MÅ TI ON TO FR LÖ)
+ ;; '(SÖ MÅ TI ON TO FR LÖ)
(take (drop (apply circular-list (iota 7))
week-start)
7))))
- (tbody ,@(let recur
- ((lst (let* ((month (month date))
- (month-len (days-in-month date))
- (prev-month-len (days-in-month (month- date)))
- (month-start (modulo (- (week-day date) week-start) 7)))
- ;; ... 28 29 | 1 2 ... 30 31 | 1 2 ...
- (append (map (td '(class "prev") (month- date))
- (iota month-start (1+ (- prev-month-len month-start))))
- (map (lambda (p) `(td (@ ,@(assq-merge '((class " cur ")) (cdar p)))
- ,@(cdr p)))
- (map (lambda (d) `((@ (class ,(when (date=? today (set (day date) d))
- "today")))
- (a (@ (href "#" ,(date->string date "~Y-~m-~d"))
- (class "hidelink")) ,d)))
- (iota month-len 1)))
- (map (td '(class "next") (month+ date))
- (iota (modulo (- (* 7 5) month-len month-start) 7) 1))))))
- (unless (null? lst)
- (let* ((w rest (split-at lst 7)))
- (cons `(tr ,@w)
- (recur rest))))))))
+
+ ((tbody ,@(let* ((month (month date))
+ (month-len (days-in-month date))
+ (prev-month-len (days-in-month (month- date)))
+ (month-start (modulo (- (week-day date) week-start) 7)))
+ (define lst
+ (append
+ ;; ... 28 29 |
+ (map (td '(class "prev") (month- date))
+ (iota month-start (1+ (- prev-month-len month-start))))
+ ;; 1 2 ... 30 31
+ (map (lambda (p) `(td (@ ,@(assq-merge '((class " cur ")) (cdar p)))
+ ,@(cdr p)))
+ (map (lambda (d) `((@ (class ,(when (date=? today (set (day date) d))
+ "today")))
+ (a (@ (href "#" ,(date->string date "~Y-~m-~d"))
+ (class "hidelink")) ,d)))
+ (iota month-len 1)))
+ ;; | 1 2 ...
+ (map (td '(class "next") (month+ date))
+ (iota (modulo (- (* 7 5) month-len month-start) 7) 1))))
+
+ (let recur ((lst lst))
+ (unless (null? lst)
+ (let* ((w rest (split-at lst 7)))
+ (cons `(tr ,@w)
+ (recur rest))))))))))
(define repo-url (make-parameter "https://git.hornquist.se"))