This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-04-10
Channels
- # aleph (4)
- # architecture (4)
- # aws (1)
- # beginners (64)
- # cider (26)
- # clara (9)
- # cljs-dev (45)
- # cljsrn (1)
- # clojars (8)
- # clojure (31)
- # clojure-finland (3)
- # clojure-italy (3)
- # clojure-nl (3)
- # clojure-poland (9)
- # clojure-spec (1)
- # clojure-uk (81)
- # clojurescript (35)
- # core-async (1)
- # cursive (33)
- # datomic (29)
- # editors (4)
- # emacs (2)
- # fulcro (22)
- # jobs (4)
- # leiningen (2)
- # off-topic (20)
- # onyx (1)
- # portkey (17)
- # proton (2)
- # re-frame (20)
- # reagent (36)
- # remote-jobs (1)
- # ring-swagger (1)
- # rum (2)
- # shadow-cljs (179)
- # slack-help (1)
- # spacemacs (1)
- # test-check (20)
maanmaan
@mccraigmccraig Good point. My local cycle club does a loop towards the south east of Manchester and we always end up in the Peaks somewhere. Some lovely views and 'lovely' hills
great off-road too... i did a ladybower reservoir circuit some time last year, which was a lot more entertaining than anything i've met down here
I own an old hardtail MTB and do go out occasionally, but given how badly I faired when someone else in the club took a few of us out for a 'beginner ride' where he was on a single speed rigid I think it's road riding for me
haha, you get used to the off-road stuff quite quickly, then someone suggests you go on a trip to BPW and the next thing you know you are practising wheelies and manuals (still can't do 'em, but i am practising 😬 ) and jumps and stuff...
plus i get that snowboard-like feeling of absolute flow-concentration off-road, which i never seem to get on-road
@jasonbell your current avatar reminds me of this - https://static3.srcdn.com/wp-content/uploads/2016/10/Ash-Vs-Evil-Dead-Chainsaw.jpg?q=50&w=786&h=393&fit=crop&dpr=1.5
(from a blurry distance anyway)
@mccraigmccraig I can see that
morning everyone!
Does anyone in here know how to do the following using clojure.java-time? I want to calculate the number of months between 2 dates. So for example, if num-months existed as a function:
(num-months (clojure.java-time/local-date 2018 7 1) (clojure.java-time/local-date 2018 9 30))
Can I literally subtract the more recent date from the more distant date and then use:
(months ...)
quick google gives back this
https://stackoverflow.com/questions/28355746/get-difference-between-datetime-instances-with-clj-time
and there is a in-months
function
(I could use clj-time / Joda for this in parallel to clojure.java-time, but I'd rather stick to one paradigm then that wins imho)
I use java.time quite a bit, and would probably drop down to java interop to get the number of months between two dates. eg. (.until local-date-a local-date-b ChronoUnit/MONTHS)
@peterwestmacott - Thanks very much, sorry I went into a long meeting
@guy - Yeah, that's my thinking, but I don't have the Java knowledge to know the answer.
I'm always vaguely surprised when Clojure devs haven't had to do work around the Java ecosystem and importing and using Java libs, but thinking about it 99% of what we've done with it is either Kafka or datetime 😉
@peterwestmacott - Do you know off the top of your head where I can (:import ...) ChronoUnit from, please?
I am going to be going to look at the JavaDocs, but if you happen__ to know then that's easier 😉
it’s in the java.time.temporal
package
(sorry, was not paying attention to Slack for a bit)
No worries @peterwestmacott - thanks very much
Weird results however... Notionally I would expect that 2018/07/01 -> 2018/09/30 would be 3 months, but Java says that it's 2
if you want to do your own rounding, then you could try ChronoUnit/DAYS
and round it manually
at some point you have to decide what a ‘Month’ is though before you settle on an approach
is it ‘30 days’?
I want to be able to do Calendar months, i.e. "How many months is this on a calendar?"
well how many is it?
it looks like two whole months and then some days to me
it isn’t all of september (imho)
intervals are usually exclusive at one end
A non-programmer will see 1st July to 30th September as start of 1st of July to end of 30th September
if your 30th September is meant to represent the end of the month, then maybe you want to either a) include a time component and make it the instant of midnight on the first day of the next month, or b) increment by one day prior to your month calculation
I get that there is a mathematical answer that is more accurate, but non-programmer, users are not seeing that mathematical reality
I think that adding 1 day to the end-date in the background (i.e. hidden from the user) is the way to get accurate date maths in this case.
the trouble is that even with the right date/time libraries you still have to think about dates and times
that probably is the ‘good enough’ solution here
I've had a better idea, @peterwestmacott - take the days out of the equation and let the user only choose year and month
if that’s all the precision you need then that sounds good
There’s a java.time class for that
java.time.YearMonth