0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-08 16:00:19 -05:00
penpot/frontend/uxbox/time.cljs

39 lines
621 B
Clojure

(ns uxbox.time
(: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)))))
(defn ago
[time]
(.fromNow (parse time)))
(defn day
[time]
(.calendar (parse time)
nil
#js {:sameDay "[Today]"
:sameElse "[Today]"
:lastDay "[Yesterday]"
:lastWeek "[Last] dddd"}))