Skip to content

Instantly share code, notes, and snippets.

@CampingScorpion
Created October 24, 2011 01:04
Show Gist options
  • Save CampingScorpion/1308149 to your computer and use it in GitHub Desktop.
Save CampingScorpion/1308149 to your computer and use it in GitHub Desktop.
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