Skip to content

Instantly share code, notes, and snippets.

@aoba17
Last active June 11, 2020 07:11
Show Gist options
  • Save aoba17/621af0b2a9bae1d066da70e164614eb5 to your computer and use it in GitHub Desktop.
Save aoba17/621af0b2a9bae1d066da70e164614eb5 to your computer and use it in GitHub Desktop.
(def dt-a (js/Date. "2020-05-01"))
(def dt-b (js/Date. "2020-05-30"))
(def mills<->days (* 1000 60 60 24))
(defn get-duration
"2つの日付の差分(日数)を求める"
[dt-a dt-b]
(/ (- dt-b dt-a) mills<->days))
(get-duration dt-a dt-b) ;-> 29
(def today
"今日の日付"
(let [now (js/Date.)
year (.getFullYear now)
month (inc (.getMonth now))
date (.getDate now)]
(js/Date. (str year "/" month "/" date))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment