I've adapted the code from this Java answer into my date-dif function:
(defn date-dif [d1 d2]
(let [tu java.util.concurrent.TimeUnit/SECONDS
t1 (. d1 getTime)
t2 (. d2 getTime)]
(. tu convert (- t2 t1) java.util.concurrent.TimeUnit/MILLISECONDS)))
(defn start-timer []
(let [cur-time (new java.util.Date)]
(fn [] (date-dif cur-time (new java.util.Date)))))
start-timer
will create and return a function that, when called, returns the number of seconds since the function was created. To use it, do something like this:
rpg-time.core> (def my-timer (start-timer))
#'rpg-time.core/my-timer
rpg-time.core> (my-timer)
3
rpg-time.core> (my-timer)
5
rpg-time.core> (my-timer)
6
If you want a different unit of time, instead of seconds, replace SECONDS with something more appropriate from here.
There are certainly other options you can consider. This is just the first one I thought of, and it isn't very hard to code or use.