PostgreSQL can be pretty fussy about date/time fields -- see for example https://cljdoc.org/d/seancorfield/next.jdbc/1.1.613/doc/getting-started/tips-tricks#working-with-date-and-time -- but you'll definitely want to be using an actual date/time value and not a string.
If you're using clojure.java.jdbc
, I'll point out that's not actively maintained any more and you should consider using next.jdbc
(the latter is the "1.0" release that I was not able to give c.j.j because I needed to make some big changes, based on what I'd learned maintaining c.j.j for many years).
Also, that SO answer suggests clj-time
@highpressurecarsalesm which is deprecated now and the readme recommends either using Java Time directly or one of the wrapper libraries (and, yes, clj-time
is another one of my libraries where I want people to migrate off it to something else 🙂 ).
Thanks a lot!
Hi! 🙂 About MongoDB. Does anyone here know how the monger library (via the mongodb java driver) converts the internal JSON data structures to and from Clojure data types?
Documentation says: "Monger does not try to offer object/document mapping functionality. With Monger, you work with native Clojure and Java data structures like maps, vectors, strings, dates and so on"
Conversion seems very fast so I am trying to find out why. :)
I guess there are some BSON <-> clojure converter involved
hello, is there an easy way to get the formatted time elapsed since a given date (for example: "5days ago") in clojure?
@lkottmann have a look at tick - it uses Java-time and you can use it in both clj and cljs https://github.com/juxt/tick
looks interesting, don't know why I went past it, thanks
it doesn't seem to support humanizing a time "ago" (i.e: "5 days ago")
but it's definitely more complete than java-time
Oh @lkottmann I'm sorry I completely missed the point of your initial message. Try this https://duckling.wit.ai/
actually I replaced my code with and it's much better already
that duckling lib looks awesome
I never saw it before!
I'm trying to see if it can handle the reverse (a duration to a humanized representation)
mmh it doesn't seem to do that, and it has been deprecated in favor of an haskell version from facebook 😕
@lkottmann sorry I can't help much. I don't think it would be too hard to implement one, though. And at the end you can publish that as a lib 🙂
well, I did but I didn't make into a library
(uses tick
)
Just a quick tip (as a user) - I personally don't like when apps do that. I even have JS tweaks to replace the "... ago" on github. So please remember some people might not want that "feature". So I'd add that as an configurable option.
I use it for knowing how long ago an app was deployed, and my users are my employees so it's fine ^^
Hello, i have to develop web app with clojure (API) + vue.js. Is there any framework that nearly equal to express.js? Are Ring + http-kit recommended? I haven't completely read about them yet. The project is relatively small only crud stuffs and user administration.
Searching for clojure humanize
got me to https://github.com/trhura/clojure-humanize#datetime
this uses clj-time and I was told to use java-time now
datetimes in Java-land are a nightmare..
Ok I have the stupidest thing that I've been staring at for too long...
Syntax error compiling at (/tmp/form-init9098034618826095313.clj:1:73).
No namespace: devbots.bots.vacation
ls -l src/devbots/bots/vacation.clj
-rw-rw-r-- 1 stefan stefan 1538 Nov 27 18:15 src/devbots/bots/vacation.clj
head src/devbots/bots/vacation.clj
(ns devbots.bots.vacation
(:require [devbots.events :as events]
[devbots.github :as github]
[devbots.macros :as macros]
[java-time :as jt]))
(ns devbots.dispatcher
(:require [taoensso.timbre :as timbre :refer [info]]
[taoensso.carmine :as car :refer [wcar]]
[taoensso.carmine.message-queue :as mq]
[clojure.core.cache.wrapped :as cache]
[devbots.events :as events]
[devbots.util :as util]
[devbots.bots.vacation :as vacation]
[devbots.bots.lock-issue :as lock-issue]
[devbots.bots.lock-pull-request :as lock-pull-request]
[devbots.bots.needs-triage :as needs-triage]
[devbots.bots.needs-review :as needs-review]))
That is where it fails ...
The file is in the right place with the right name with the right ns
.. so wth
OMG ... I had a test/devbots/bots/vacation.clj
which I just renamed to vacation_test.clj
(it did have the right devbots.bots.vacation-test
namespace though
@raefaldhiamartya We have used both Jetty and http-kit at work. They're pretty much interchangeable although http-kit claims to be faster -- but most monitoring/observability solutions out there work much better with Jetty (we ended up switching from http-kit to Jetty because we use New Relic and it doesn't work very well with http-kit).
(rubber-duck debugging: figuring out the solution, just by explaining it to someone else)
Thanks @seancorfield! I will look into the code. 🙂
yup
being a lone coder is not always easy
i do think out loud, but writing it down usually helps better 🙂
for the "time ago" thing, I ended up (painfully) writing this
I hear ya! Although I have a team mate, we've always worked remotely, so we're both almost "lone coders" 🙂
I see logging is still the same mess I remember it was
@st3fan After a lot of back and forth at work, we ended up settling on clojure.tools.logging
and log4j2 (and setting the JVM option -Dclojure.tools.logging.factory=clojure.tools.logging.impl/log4j2-factory
(and using the log4j2 adapters to pipe all the other logging libs through it)
;; use log4j 2.x:
org.apache.logging.log4j/log4j-api {:mvn/version "2.13.3"}
;; bridge into log4j:
org.apache.logging.log4j/log4j-1.2-api {:mvn/version "2.13.3"}
org.apache.logging.log4j/log4j-jcl {:mvn/version "2.13.3"}
org.apache.logging.log4j/log4j-jul {:mvn/version "2.13.3"}
org.apache.logging.log4j/log4j-slf4j-impl {:mvn/version "2.13.3"}
Right now I see Jetty and my own logging end up in different formats in the console ..
Yup, another reason to bridge all logging into one place.
This sounds like something I should pour at least an hour into to understand and get right
Clojure is a side project for me ... work is all Kotlin 🙂
Kotlin is nice. Better than Java or Scala 🙂
I don't even write Kotlin actually - I'm managing the team, not writing code 😉
coders gonna code
Maybe I should find a Clojure job and get paid to do this
is Clojure considered a really expressive language? meaning... can represent almost any algorithm or idea.
yes and what the foundational clojure forms cannot express well you can build with macros and functions
Can someone help me understand why this throws an error?
((fn [start stop]
(loop [start start
stop stop]
(if (start >= stop)
start
(recur (inc start)
stop)))) 1 4)
because (start >= stop) should be (>= start stop)
oh my goodness :man-facepalming:
or maybe <= i also get confused with the notation 🙂
no worries, earliet today i typed something like (defun something [] (return 123)) 🙂
i keep being oblivious to that from time to time
i find it specially hard when switching between languages
yeahh, i think everything clicks but conditionals tends to be something i skip over
I suppose I also need to understand how to read clojure error messages better - couldn't tell what error my line was on. So i thought the issue was with recur
Some of my roles have involved more management or more architecture than actual coding -- that's when my OSS projects get a lot more attention! When work is heavy coding, my OSS projects take a back seat. I just have to code to stay sane 🙂
here's a question of spec
s and namespace
s:
I defined:
(ns minimal.spec
(:require
[clojure.spec.alpha :as s]))
(s/def ::my-spec ...)
and in the main file:
(ns minimal.core
(:require
[clojure.spec.alpha :as s]
[minimal.spec :as spec]))
(s/conform :spec/my-spec ...)
but I get
unable to resolve spec: :spec/judgement
what's going on?@meditans You need ::spec/judgement
so the alias is auto-resolved.
(you have a single :
instead of a double ::
)
thanks @seancorfield (I can't wait to see your talk on the repl btw). But why do I need to autoresolve that? isn't :spec/judgement
equivalent to :minimal.spec/judgement
given my import? I was under the impression (maybe wrong) that ::
added the current module
(I mean, it works, but I can't see why)
No. :foo/bar
is always just :foo/bar
. But ::foo/bar
will expand an alias foo
into its namespace.
In the same way that ::bar
expands to :current.namespace/bar
I see, so without the ::
there's no namespace substitution! Thanks! Where can I find the complete semantic of ::
?
I was just looking on http://clojure.org for that... I suspect it might be in the Reader section...
https://clojure.org/guides/weird_characters#autoresolved_keys (and the following section about namespace map syntax) touch on it -- but don't really show aliases being expanded...
Oh, they do give an example further down in the namspace map syntax section!
I see, thanks for the pointer 🙂