juxt

Cezary 2023-04-28T17:15:56.153169Z

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.

Cezary 2023-05-08T14:33:39.456239Z

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.

tomd 2023-04-28T17:30:17.111189Z

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

Cezary 2023-04-28T17:33:48.873659Z

Ayyyy so many time libraries

😆 1
tomd 2023-04-28T17:35:41.821929Z

I'd say make an issue or PR to add to tick, but I'm not sure how common parsing epoch seconds is 🤔

Cezary 2023-04-28T17:36:51.376039Z

Well... I guessed common enough to have support in a new lib. Thanks for the tip. Will do.

👍 1
2023-05-07T19:46:57.522019Z

> 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

👍 1