If you use Clojure in the JVM, consider using the PrettyTime library . Using this library to implement the "time back" in Java has been proposed here .
PrettyTime Clojure, :dependencies project.clj:
[org.ocpsoft.prettytime/prettytime "3.2.7.Final"]
Java interop. , " " 1 . , . , , , . " " " ". , .
(import 'org.ocpsoft.prettytime.PrettyTime
'org.ocpsoft.prettytime.units.JustNow
'java.util.Date)
(defn time-ago [date]
(let [pretty-time (PrettyTime.)]
(.. pretty-time (getUnit JustNow) (setMaxQuantity 1000))
(.format pretty-time date)))
(let [now (System/currentTimeMillis)]
(doseq [offset [200, (* 30 1000), (* 5 60 1000)]]
(println (time-ago (Date. (- now offset))))))
;; moments ago
;; 30 seconds ago
;; 5 minutes ago