forked from dm3/clojure.java-time
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsugar.clj
More file actions
19 lines (16 loc) · 743 Bytes
/
sugar.clj
File metadata and controls
19 lines (16 loc) · 743 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
(ns java-time.sugar
(:require [java-time.core :as jt.c]
[java-time.util :as jt.u]))
(doseq [[day-name day-number]
[['monday 1] ['tuesday 2] ['wednesday 3] ['thursday 4] ['friday 5]
['saturday 6] ['sunday 7]]]
(eval `(defn ~(symbol (str day-name '?))
~(str "Returns true if the given time entity with the\n"
" `day-of-week` property falls on a " day-name ".")
[o#] (if-let [p# (jt.c/property o# :day-of-week)]
(= (jt.c/value p#) ~day-number)
(throw (java.time.DateTimeException. (str "Day of week unsupported for: " (type o#))))))))
(defn weekend? [dt]
(or (saturday? dt) (sunday? dt)))
(defn weekday? [dt]
(not (weekend? dt)))