Fork me on GitHub
#juxt
<
2020-06-10
>
Joe12:06:33

Hi! I'm using juxt/tick and I want to know how many days are in a period P2M . At a higher level, I'm looking to calculate the fraction of a year a period represents, if that's simpler. Thanks

Joe13:06:49

I should specify that I do start out with two dates to generate the period - thinking about it, you can't say exactly how many days are in a month. So I guess what I'm actually looking for is the number of days between two dates

Johanna13:06:03

Have you tried a combination of between and divide?

Johanna13:06:13

(tick/divide (tick/between <some instant> <some other instant>)
(tick/new-duration 1 :days))

Johanna13:06:34

This would work for durations (between gives a duration) but not for periods, for the reasons you've just given.

Joe13:06:37

I did have a look at divide - but as you say I was using periods and I was getting some thing like ‘doesn’t work on estimates’. It sounds like converting the dates I was using to instants before calling between would solve that. I’ll give it a go, thanks!

👌 4
Joe12:06:40

I tried days but that's obviously not what it's for.

dominicm13:06:57

count t/range