This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-04-28
Channels
- # aleph (3)
- # announcements (3)
- # babashka (8)
- # beginners (12)
- # biff (4)
- # calva (12)
- # clerk (29)
- # clj-kondo (1)
- # clojure (104)
- # clojure-art (1)
- # clojure-austin (5)
- # clojure-berlin (3)
- # clojure-brasil (34)
- # clojure-europe (11)
- # clojure-germany (16)
- # clojure-losangeles (9)
- # clojure-nl (30)
- # clojure-norway (58)
- # clojure-uk (1)
- # core-async (8)
- # cursive (4)
- # data-science (9)
- # datalevin (1)
- # datomic (40)
- # emacs (2)
- # events (3)
- # helix (1)
- # honeysql (3)
- # hugsql (1)
- # hyperfiddle (66)
- # jobs (4)
- # juxt (7)
- # kaocha (9)
- # lsp (5)
- # malli (10)
- # off-topic (4)
- # polylith (2)
- # reitit (5)
- # releases (1)
- # remote-jobs (5)
- # sci (46)
- # scittle (2)
- # shadow-cljs (9)
- # tools-deps (17)
- # xtdb (8)
Hey guys, is there a better way to read time given in epoch seconds in tick in the other way than below? The docs didn't help me - maybe my mistake.
(defn epoch->time [seconds]
(t/>> (t/epoch) (t/new-duration seconds :seconds)))
Is this really the way I should do it? I hope not. Seems sketchy.I don't think tick has this built in, but cljc-time (which tick uses) has of-epoch-second
if that's helpful to you
I'd say make an issue or PR to add to tick, but I'm not sure how common parsing epoch seconds is :thinking_face:
Well... I guessed common enough to have support in a new lib. Thanks for the tip. Will do.
> I'm not sure how common parsing epoch seconds is For me, pretty common. Lots of systems/APIs report time in epoch seconds or epoch milliseconds, and I convert/coerce them to a zoned datetime ASAP. My utility fns:
(defn ems->
([x]
(ems-> "UTC" x))
([tz x]
(-> x
t/instant
(t/in tz))))
(defn es->
([x]
(es-> "UTC" x))
([tz x]
(ems-> tz (* x 1000))))
N.B "ems" == Epoch Milli Seconds, and "es" == Epoch SecondsThanks, that's exactly what I did (-> seconds (* 1000) t/instant)
. *Therefore I take back the lack of epoch parsing in tick.* https://github.com/juxt/tick/issues/186.