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.Thanks, 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.
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 🤔
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 Seconds