Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added time helpers to util

  • Loading branch information...
commit 7aef2eaf98ea74446bd88fda731327d572186be0 1 parent a111999
@zk authored
Showing with 21 additions and 1 deletion.
  1. +21 −1 src/cljs/nsfw/util.cljs
View
22 src/cljs/nsfw/util.cljs
@@ -52,4 +52,24 @@
(fn [& args]
(let [res (if-not @!a (apply f0 args) (apply f1 args))]
(swap! !a not)
- res))))
+ res))))
+
+(defn ms [date]
+ (.getTime date))
+
+(defn now-ms []
+ (ms (js/Date.)))
+
+
+(defn timeago [date]
+ (let [ms (ms date)
+ s (/ ms 1000)
+ m (/ s 60)
+ h (/ m 60)
+ d (/ h 24)
+ y (/ d 365)]))
+
+(defn ref? [o]
+ (instance? cljs.core/Atom o))
+
+#_(log timeago (js/Date. (- (now-ms) 100000)))
Please sign in to comment.
Something went wrong with that request. Please try again.