Create a gist now

Instantly share code, notes, and snippets.

evaluate some code at a given DateTime
(defn do-at* [date-time f]
(DateTimeUtils/setCurrentMillisFixed (.getMillis date-time))
(try
(f)
(finally (DateTimeUtils/setCurrentMillisSystem))))
;; you might use this code like this:
(do-at* (DateMidnight. 2000 1 1)
(fn [] (DateMidnight.))) ;;=> (DateMidnight. 2000 1 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment