Add query input or function day-of-week

This query should show the Day of the Week:

#+BEGIN_QUERY
{:title [:h3 "🧭️ Weekly Distribution - Disable Page View"]
 :query [:find ?d (count ?b)
       :keys date number
       :in $ ?start ?end
       :where   
       (task ?b #{"LATER" "TODO" "DOING"})
       (or [?b :block/scheduled ?d] [?b :block/deadline ?d])
       [(> ?d ?start)]
       [(< ?d ?end)]
       ]
 :inputs [:-1w :+7d]
 :collapsed? false
 :group-by ?d
 :view (fn [rows]
       [:table
        [:thead [:tr [:th "Day"] [:th "Count"]]]
        [:tbody
         (let [sorted-rows (sort-by :date rows)
           days {
            0 "Sat"
            1 "Sun"
            2 "Mon"
            3 "Tue"
            4 "Wed"
            5 "Thu"
            6 "Fri"
           }
           weekDay (fn [date]
             (def month (quot (mod date 10000) 100))
             (def month6 (quot (- month 8) 6))
             (def year6 (+ (quot date 10000) month6))
             (def yearnum (mod year6 100))
             (def century (quot year6 100))
             (def d (mod (+ (mod date 100) (quot (* 13 (inc (- month (* month6 12)))) 5) yearnum (quot yearnum 4) (quot century 4) (* 5 century)) 7))
             (get days d)
            )
          ]
           (for [r sorted-rows]
             [:tr
              [:td (str (get-in r [:date]) " " (weekDay (get-in r [:date])))]
              [:td (get-in r [:number])]]))]])
}
#+END_QUERY
4 Likes