Fork me on GitHub

Does anyone know of a complete parser for the date format? There are so many caveats to the format and all the examples I've found online seem to fail.


I got pretty close with "yyyy-MM-dd'T'HH:mm:ss[.SSS]ZZZZZ" pattern + parseBest but rfc3339 includes leap seconds which means seconds can go to 60 and causes it to fail 😞


Leap seconds are only valid at certain times, the end of June or December, have you been testing your parsering with date times where leap seconds are valid?


Testing with 1990-12-31T15:59:60-08:00


Execution error (DateTimeException) at java.time.temporal.ValueRange/checkValidIntValue (
Invalid value for SecondOfMinute (valid values 0 - 59): 60


> java.time does support the parsing of a (valid) leap second.


I think this works!

  (DateTimeFormatter/ofPattern "yyyy-MM-dd'T'HH:mm:ss[.SSS]ZZZZZ")


For those interested, this is the final code that seems to work with all my examples

(def rfc-3339-formatter
    (DateTimeFormatter/ofPattern "yyyy-MM-dd'T'HH:mm:ss[.SSS]ZZZZZ")

(defn parse-rfc-3339-to-instant
  (-> (LocalDateTime/parse date-string rfc-3339-formatter)
      (.atZone (ZoneId/of "UTC"))


I'm trying to use cheshire to create a JSON lines dataset. I wrote a working function that I am reasonably happy with.

(defn write-jsonl
  [rows writer]
  (doseq [row rows]
    (ch/generate-stream row writer {:escape-non-ascii true})
    (.write writer "\n")))
Does anybody know if there is a cleaner way to get the newline rather than a separate call to .write ? Perhaps a cheshire option that I can't find in the docs?

Jessie R06:03:30

Hi, I am looking at spec-ing some code and I wanted to make a set extensible; (s/def ::type #{:local-file :s3}) such that in another file, I could add on another type e.g. :sftp

Jessie R06:03:37

Is there a way to do this?


Just use keyword?


Hello everyone! Just trying my luck here: has anybody successfully enabled OS X clojure build via Travis CI/CD? Seems like they only support linux and win out of the box... Edit: made it work if anyone is interested - just needed to add leiningen into addons: seems quite simple, so I am not sure why Travis states: "Clojure builds are not available on the macOS environment."

language: clojure
    - os: osx
      jdk: openjdk11
          - leiningen
          update: true


I have a project which has a deps.edn dependency to a private repo, Clojure deps is failing to pull the dependency with:

Cloning: [email protected]:grzm/psycho-roll.git
Error building classpath. [email protected]:grzm/private-repo.git: invalid privatekey: [B@1653b84e
org.eclipse.jgit.api.errors.TransportException: [email protected]:grzm/private-repo.git: invalid privatekey: [B@1653b84e
Seems like it’s an issue with my SSH keys, but I’m a bit puzzled as I can clone this same dependency from from the command line with git clone without any problem, and the necessary keys show up when using ssh-add -l. Hints on what I might be doing wrong?


Try #tools-deps channel But i know that by design, all auth settings are on git.


Thanks for the pointer to the #tools-deps channel 🙂

Eduardo Mata13:03:47

I have a vector of one or two map elements [{:x 'x} {:y y}] and I would like to create a replica of those two maps and append them to an accumulator vector. I primarily iterate to each one of them and append it to the acc-vector such as (map #(swap! acc-vector conj (do-something %)) original-vector). Is there an actual function for this? if not then I keep this approach


you are mixing lazy sequences (map) with side effects (swap!), this is very very bad


use run! instead of map

Eduardo Mata14:03:56

great recommendation

Eduardo Mata14:03:05

Because we are talking about this, I am using async and I use map. Should I use run! instead for the following example?

(defn upsert-legs!
  (let [leg-chan (chan 1024)
        match-chan (chan 1024)
        upsert-chan (chan 1024)]
    (onto-chan leg-chan legs)
    (pipeline-blocking 16 match-chan (map match-leg) leg-chan)
    (pipeline-blocking 16 upsert-chan (map upsert-leg!) match-chan)))


ah, thats not lazy sequences, thats transducers


hey folks, i get this reflection error when trying to call static method like this: (Cls/foo ...), any way i can unconfuse reflection machinery to see that it's Cls being called, not xyz.core$eval6024? Cls is gen-classed in another namespace if that matters


I’m writing a simple transpiler, in first step I parse original source into clojure datastructures and then in second step I take that data and emit output text. The problem is that my data is a deeply nested structure containing lazy sequences (produced by map, etc.) and when the structure is realized during emit I might get some errors/exceptions. And for that I would need some context info to print meaningful error messages. I didn’t want to pass context explicitely down through all the calls. I wanted to use something like binding to set some context at the top level and use it later when I hit exceptional state. Any ideas how to do that?


currently I opted in forcing recursive realization of the datastructure (using doall) at some well defined points and with dynamic binding to set current context info, but that has some issues


What is a way to read transit from stdin while only relying on core or standard Java features?

$ echo "{:a 1}" | jet --to transit | ./bb '(transit/read (transit/reader ... :json))'


System/in is InputStream, you should be able to use it for reading


yay, that worked!

$ echo "{:a 1}" | jet --to transit | ./bb '(transit/read (transit/reader System/in :json))'
{:a 1}


thanks. that's good to know


anyone have a good reference handy for a macro that is a def-function-like? Ie parsing dosctring and arities




not sure what you need, but if you're looking for code that parses an expression like defn does, it might be good at the code for defn


good point actually there's a lot in clojure.core, I'll check out sci next, thanks!


(I just stole the destructure implementation in sci for something else actually) 🙂


that implementation was stolen from clojure.core in the first place


yeah I figured


a combination of clojure.core and cljs.core actually. sometimes I find the code in cljs.core a little bit clearer


I didn't actually look how close they were. Just needed it to work on pure cljs


then you might as well copy it from clojurescript


Any ideas about the reflection issue above?


If you import the relevant Java class (e.g., ExpectedFooClass), you can provide a hint to your function call: (CIs/foo ^ExpectedFooClass foo)


Alternatively, if foo is being passed in as an argument, you can provide the hint there:

(defn foo-wrapper [^ExpectedFooClass foo]
  (CIs/foo foo))


the problem is somehow in Cls/foo itself. it's static method inherited from ClsSuper/foo and it's looking up the caller stack to make sure Cls extends ClsSuper but somehow fails that check. clojure uses invokeStatic to call Cls/foo and that makes it not be in the stacktrace somehow? i don't know..


at at xyz$eval6024.invokeStatic(form-init1514362494284450037.clj:19) supposedly there should be a line with Cls.launch in between here, right?


GameApplication is the "ClsSuper" here


no of course there shouldn't be, i don't override .launch


I strongly suspect that if the lib relies on implementation details of how java implements inheritance and superclass method invocation, the simplest and least error prone thing is to write a java stub that invokes clojure functions in all its method bodies


each method would use to look up an ns and call a function


or just write it all in java if that's easier


just in case anybody else stumbles across this, the problem was in implicit assumption that caller of .launch is a class that extends a certain super, which it is not if .launch is invoked directly from clojure code

👍 4

hello! What is the current state of clojure development for android?


If you’re looking for UI-building tools, these are the two I’m aware of :,


(both based on React Native)


so it's cljs/react rather than clj/java?


how different is it to work with as somebody only used to desktop java clojure?


I’d assume very. But I’m assuming desktop java clojure involves a lot of imperative code. Do you use a particular library or framework for desktop java/clojure UI dev?


well, I mostly write CLI apps on the desktop, but I've used seesaw for UI in the past


I'm mostly thinking in terms of actual language differences/workflow


react native is pretty different in terms of work flow


there’s a whole other React Native toolchain you use, along with the ClojureScript toolchain


that being said, it’s pretty useful to know. you can currently build UIs for windows, macOS, iOS and Android with React Native, and it gets more feature complete and advanced as time goes on


is cljs + react native the current best way to build clojure apps for android then?


yes, i would say so


fundamentally, getting clojure to run on android is difficult; there are differences between mainstream JVMs and the android runtime. and the Clojure startup time is a big UX problem on smaller devices


alright, thanls


If you only worked with Java, adjusting to JavaScript as host might require some learning. That being said React Native + shadow.cljs is becoming really nice app-development platform. Resulting applications also work quite nice, and there’s more and more useful bridges to native code. The biggest problem, probably, is that you’re gonna have to read documentations and issues of JavaScript tools, you might not be familiar with