Add java.time.temporal.ChronoUnit class (#271)

* Adding java.time.temporal.ChronoUnit to classes.clj

This enables the two following kinds of calculations between
LocalDateTime, LocalTime, Instant and other Temporal descendants:

ChronoUnit.MILLIS.between(temporalOne, temporalTwo)
temporalOne.until(temporalTwo, Chronounit.HOURS)

and I assume a lot of other operations which require time
units.

* Add unit test

Co-authored-by: Matias Bjarland <matias@iteego.com>
This commit is contained in:
Michiel Borkent 2020-02-21 21:32:28 +01:00 committed by GitHub
parent 7b30927a12
commit a4b4ce43a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions

View file

@ -57,6 +57,9 @@ Keep notes here about how adding libraries and classes to Babashka affects the b
<!-- 2020/01/08, ..., 38.7mb / 11.3mb zipped -->
<!-- Added: `clojure.data.xml`. Growth: 1.8mb / ... -->
2020/02/21,
Added java.time.temporal.ChronoUnit
40651596 - 40598260 = 53kb added.
2020/02/19, e43727955a2cdabd2bb0189c20dd7f9a18156fc9
Added fipp.edn/pprint

View file

@ -83,6 +83,7 @@
java.time.ZonedDateTime
java.time.ZoneId
java.time.ZoneOffset
java.time.temporal.ChronoUnit
java.time.temporal.TemporalAccessor
java.util.regex.Pattern
java.util.Base64

View file

@ -16,4 +16,8 @@
(is (= "18-12-2019 16:01:41"
(bb '(.format
(java.time.LocalDateTime/parse "2019-12-18T16:01:41.485")
(java.time.format.DateTimeFormatter/ofPattern "dd-MM-yyyy HH:mm:ss"))))))
(java.time.format.DateTimeFormatter/ofPattern "dd-MM-yyyy HH:mm:ss")))))
(is (number? (bb "
(let [x (java.time.LocalDateTime/parse \"2019-12-18T16:01:41.485\")
y (java.time.LocalDateTime/now)]
(.between java.time.temporal.ChronoUnit/MINUTES x y))"))))