Skip to content

Instantly share code, notes, and snippets.

@tmountain
Last active January 23, 2017 20:45
Show Gist options
  • Save tmountain/86a186d0c703667aff7975109aa69311 to your computer and use it in GitHub Desktop.
Save tmountain/86a186d0c703667aff7975109aa69311 to your computer and use it in GitHub Desktop.
(def jira-time-format (f/formatter "yyyy-MM-dd HH:mm"))
(def short-time-format (f/formatter "yyyy-MM-dd"))
(defn get-time-series
([start-date end-date]
(let [start-date (f/parse jira-time-format start-date)
end-date (f/parse jira-time-format end-date)]
(get-time-series start-date end-date start-date [])))
([start-date end-date current-date series]
(if-not (t/within? (t/interval start-date end-date) current-date)
series
(recur start-date
end-date
(-> current-date (.plusDays 1))
(conj series (f/unparse short-time-format current-date))))))
(get-time-series "2017-01-01 22:46" "2017-01-13 17:00")
; ["2017-01-01" "2017-01-02" "2017-01-03" "2017-01-04" ... ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment