This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-12-01
Channels
- # adventofcode (66)
- # announcements (12)
- # aws (8)
- # babashka (28)
- # beginners (160)
- # cider (28)
- # clara (22)
- # clj-kondo (5)
- # cljdoc (40)
- # clojure (129)
- # clojure-australia (2)
- # clojure-europe (24)
- # clojure-gamedev (19)
- # clojure-nl (5)
- # clojure-norway (15)
- # clojure-sanfrancisco (25)
- # clojure-seattle (2)
- # clojure-spec (13)
- # clojure-uk (29)
- # clojurescript (14)
- # cryogen (5)
- # cursive (7)
- # data-science (1)
- # datascript (5)
- # datomic (8)
- # deps-new (5)
- # emacs (19)
- # events (8)
- # fulcro (32)
- # graalvm (7)
- # helix (9)
- # kaocha (3)
- # lambdaisland (1)
- # london-clojurians (4)
- # malli (5)
- # meander (32)
- # off-topic (143)
- # pathom (4)
- # portal (32)
- # re-frame (7)
- # reagent (33)
- # reitit (2)
- # shadow-cljs (5)
- # spacemacs (4)
- # tools-deps (30)
- # vim (1)
Morning
morning
¡månmån¡
Morning All 🙂
Does anyone have a quick / reliable way to make #inst "2020-12-01T12:00:00"
have a timezone, so that it can be formatted using the date / time formatting functions in clojure.java-time?
I get a type error when I try to do this:
(jt/format "dd/MM/yyyy" #inst "2020-12-01T12:00:00")
and I am pretty sure that this is because a bare Clojure Instant has no timezone info as it is assumed to be UTC
Technically, an instant has no timezone because it’s the number of seconds elapsed since the epoch moment (Jan 1st 1970 at 00:00:00 UTC), which is the same number of seconds anywhere
where your datetime is dt
, (str dt "Z")
with the obvious caveat that this works IIF the format is exactly as above lol in practice i'd parse it and then coerce it using a lib and a threading form
i know, def a case of 'just because you can doesn't mean you should' hahaha
quick and dirty but then it's utc/z
In the spirit of full disclosure, this is the solution I have (now):
(jt/format "dd/MM/yyyy" (.atZone (.toInstant #inst "2020-12-01T12:00:00") (jt/zone-id)))
but i would like something less unwieldy and less Java-y if it's possible.
(assume that #inst "2020-12--1T12:00:00"
would actually be passed in as a value / input)
Morning
@maleghast there's 2 things you might want to have happen here:
1. You want to have 2020-12-01T12:00:00 in the target timezone. E.g. a shift into Tokyo would be "2020-12-01T12:00+09:00[Asia/Tokyo]"
2. You want to shift from UTC to the target timezone. E.g. a shift into Tokyo would be "2020-12-01T21:00+09:00[Asia/Tokyo]"