Holi is a Clojure and ClojureScript library for working with non-business days
(ns my-app
(:require [luciolucio.holi :as holi]
[tick.core :as t]))
; July 2019
; Su Mo Tu We Th Fr Sa
; 1 2 3 4 5 6
; 7 8 9 10 11 12 13
; 14 15 16 17 18 19 20
; 21 22 23 24 25 26 27
; 28 29 30 31
(holi/add (t/date "2019-07-12") 3 :business-days) ; 17Jul2020 (skips weekends)
(holi/add (t/date "2019-07-03") 1 :business-days "US") ; 5Jul2019 (skips 4th of July as a US holiday)
(holi/weekend? (t/date "2019-07-06")) ; -> true
(holi/holiday? (t/date "2019-07-04") "US") ; -> true
Use of juxt/tick is not required (but highly recommended).
Import the latest version from clojars into your project dependencies
Holi has been successfully tested when built with shadow-cljs and run on a browser. If you have issues with other setups,
hit me up on Slack: @Lucio Assis
Visit cljdoc for the public API docs
Use n = 0
to get same or next semantics, that is:
n = 1
(ns my-app
(:require [luciolucio.holi :as holi]
[tick.core :as t]))
(holi/add (t/date "2022-07-06") 0 :business-days) ; -> 8Jul22, because 6Jul22 is a Saturday
(holi/add (t/date "2022-07-07") 0 :business-days) ; -> 8Jul22, because 7Jul22 is a Sunday
(holi/add (t/date "2022-07-08") 0 :business-days) ; -> 8Jul22, as it's a regular Monday
One way this is useful is for things like "This is due next month, on the same day of the month, but if it's a weekend then it's the following business day":
(-> (t/date "2022-06-06")
(holi/add 1 :months) ; 6Jul22, Sat
(holi/add 0 :business-days)) ; 8Jul22, Mon
Holiday calendar | Description |
---|---|
US | United States holidays |
GB | Great Britain holidays |
BR | Brazilian holidays |
brazil/sao-paulo | São Paulo city holidays |
What do I do if a date is wrong or a holiday calendar is missing for <insert location here>?
You have two options:
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close