2015-06-18 12:35:50 -05:00
|
|
|
(ns uxbox.time
|
2015-12-15 06:00:10 -05:00
|
|
|
(:require [cljsjs.moment]))
|
|
|
|
|
|
|
|
(defn parse
|
|
|
|
([v]
|
|
|
|
(js/moment v))
|
|
|
|
([v format]
|
|
|
|
(case format
|
|
|
|
:unix (js/moment.unix v)
|
|
|
|
(js/moment v format))))
|
|
|
|
|
|
|
|
(defn iso
|
|
|
|
[v]
|
|
|
|
(.toISOString v))
|
|
|
|
|
|
|
|
(defn unix
|
|
|
|
[v]
|
|
|
|
(.unix v))
|
|
|
|
|
|
|
|
(defn now
|
|
|
|
([]
|
|
|
|
(js/moment))
|
|
|
|
([format]
|
|
|
|
(case format
|
|
|
|
:unix (unix (now))
|
|
|
|
:iso (iso (now)))))
|
2015-06-18 12:35:50 -05:00
|
|
|
|
|
|
|
(defn ago
|
|
|
|
[time]
|
2015-12-15 06:00:10 -05:00
|
|
|
(.fromNow (parse time)))
|
2015-06-18 12:35:50 -05:00
|
|
|
|
|
|
|
(defn day
|
|
|
|
[time]
|
2015-12-15 06:00:10 -05:00
|
|
|
(.calendar (parse time)
|
2015-06-18 12:35:50 -05:00
|
|
|
nil
|
|
|
|
#js {:sameDay "[Today]"
|
|
|
|
:sameElse "[Today]"
|
|
|
|
:lastDay "[Yesterday]"
|
|
|
|
:lastWeek "[Last] dddd"}))
|