This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-08-19
Channels
- # aws (2)
- # babashka (4)
- # babashka-sci-dev (7)
- # beginners (92)
- # biff (7)
- # calva (64)
- # cider (2)
- # cljsrn (14)
- # clojure (8)
- # clojure-australia (5)
- # clojure-europe (14)
- # clojure-norway (8)
- # clojure-spec (36)
- # clojurescript (19)
- # component (15)
- # cursive (1)
- # data-science (6)
- # girouette (5)
- # hyperfiddle (3)
- # juxt (5)
- # leiningen (10)
- # lsp (7)
- # malli (12)
- # nbb (90)
- # polylith (1)
- # portal (11)
- # rdf (7)
- # reagent (6)
- # reitit (40)
- # remote-jobs (1)
- # shadow-cljs (21)
- # specter (5)
- # squint (83)
- # tools-deps (17)
- # vim (7)
In tick
, is it possible to get the total number of "days" (or other unit) present in a Period ?
For example:
If I try this:
(time/days (time/between (time/date "2022-08-19") "2022-09-20"))
it returns just 1
However if I call Java Time directly, like this:
(.between java.time.temporal.ChronoUnit/DAYS (time/date "2022-08-19") (time/date "2022-09-20"))
we get the correct answer, which is 32....
Is there a tick function to get the desired answer "32"?it's not possible to get the total number of days in a period, bc e.g. a period of 1 year, 1 month and 1 day is abstract. a year can have 365 days or 366 etc
there is no direct tick equivalent to the java.time code. you can do it with cljc.java-time though:
(ns time-lib-comparison.java-time
(:require [cljc.java-time.local-date :as date]
[cljc.java-time.temporal.chrono-unit :as cu]))
(defn interval-calc [event-date]
(-> cu/days (cu/between (date/now) (date/parse event-date))))
Thanks!