Permalink
Browse files

Added time helpers to util

  • Loading branch information...
1 parent a111999 commit 7aef2eaf98ea74446bd88fda731327d572186be0 @zk committed Mar 22, 2013
Showing with 21 additions and 1 deletion.
  1. +21 −1 src/cljs/nsfw/util.cljs
View
@@ -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)))

0 comments on commit 7aef2ea

Please sign in to comment.