48 lines
1.5 KiB
Text
48 lines
1.5 KiB
Text
|
#!/usr/bin/env bb
|
||
|
|
||
|
|
||
|
(require '[babashka.deps :as deps])
|
||
|
(deps/add-deps
|
||
|
'{:deps {io.github.lispyclouds/bblgum {:git/sha "1d4de3d49b84f64d1b71930fa1161f8d2622a4d9"}
|
||
|
dev.andylu/clj-lipgloss {:local/root "/home/andy/git/clj-lipgloss"}
|
||
|
com.widdindustries/cljc.java-time {:mvn/version "0.1.21"}}})
|
||
|
|
||
|
|
||
|
(ns dev.andylu.journal-output
|
||
|
(:require [bblgum.core :as b]
|
||
|
[clj-lipgloss.core :as lg
|
||
|
:use [log]]
|
||
|
[cljc.java-time.local-date :as ld]
|
||
|
[cljc.java-time.temporal.chrono-unit :use [days]]))
|
||
|
|
||
|
|
||
|
(let [today (ld/now)
|
||
|
end-of-year (ld/of (. today getYear)
|
||
|
12
|
||
|
31)
|
||
|
span (-> (. today
|
||
|
until
|
||
|
end-of-year
|
||
|
days)
|
||
|
inc)
|
||
|
current-page (-> (b/gum :input :prompt "Current page: ")
|
||
|
:result
|
||
|
first
|
||
|
Integer/parseInt)
|
||
|
end-page 228
|
||
|
page-per-day (-> current-page
|
||
|
(+ (* -1 end-page))
|
||
|
(* -1)
|
||
|
inc
|
||
|
(/ (float span)))]
|
||
|
(log :info
|
||
|
(format "There are %s days between and including %s and %s"
|
||
|
span
|
||
|
today
|
||
|
end-of-year))
|
||
|
(log :info
|
||
|
(format "To get to page %s by the end of the year from %s, you have to write %s pages per day"
|
||
|
end-page
|
||
|
current-page
|
||
|
page-per-day)))
|