Skip to content

Commit

Permalink
Add more java classes and interfaces to support juxt.tick (#1490)
Browse files Browse the repository at this point in the history
  • Loading branch information
dvingo committed Feb 10, 2023
1 parent 30a15e1 commit ead237e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,7 @@ A preview of the next release can be installed from
[Babashka](https://github.com/babashka/babashka): Native, fast starting Clojure interpreter for scripting

## Unreleased
- Add more java.time and related classes with the goal of supporting juxt.tick https://github.com/juxt/tick/issues/86
- [#1000](https://github.com/babashka/babashka/issues/1000): add lib tests for xforms ([@bobisageek](https://github.com/bobisageek))
- [#1482](https://github.com/babashka/babashka/issues/1482): make loading of libs thread safe
- [#1487](https://github.com/babashka/babashka/issues/1487): `babashka.tasks/clojure` should be supported without arguments to start a REPL
Expand Down
6 changes: 5 additions & 1 deletion src/babashka/impl/classes.clj
Expand Up @@ -364,6 +364,7 @@
java.security.Security
java.sql.Date
java.text.ParseException
java.text.ParsePosition
;; adds about 200kb, same functionality provided by java.time:
java.text.SimpleDateFormat
~@(when features/java-time?
Expand Down Expand Up @@ -391,6 +392,7 @@
java.time.format.DateTimeFormatterBuilder
java.time.format.DateTimeParseException
java.time.format.DecimalStyle
java.time.format.FormatStyle
java.time.format.ResolverStyle
java.time.format.SignStyle
java.time.temporal.ChronoField
Expand All @@ -403,7 +405,9 @@
java.time.format.TextStyle
java.time.temporal.Temporal
java.time.temporal.TemporalAccessor
java.time.temporal.TemporalAdjuster])
java.time.temporal.TemporalAdjuster
java.time.temporal.TemporalQuery
~(symbol "[Ljava.time.temporal.TemporalQuery;")])
java.util.concurrent.atomic.AtomicInteger
java.util.concurrent.atomic.AtomicLong
java.util.concurrent.atomic.AtomicReference
Expand Down
7 changes: 7 additions & 0 deletions test/babashka/java_time_test.clj
Expand Up @@ -2,6 +2,7 @@
(:require
[babashka.test-utils :as test-utils]
[clojure.edn :as edn]
[clojure.string :as str]
[clojure.test :as test :refer [deftest is]]))

(defn bb [expr]
Expand All @@ -17,6 +18,12 @@
(bb '(.format
(java.time.LocalDateTime/parse "2019-12-18T16:01:41.485")
(java.time.format.DateTimeFormatter/ofPattern "dd-MM-yyyy HH:mm:ss")))))

(let [out (bb '(.format (java.time.LocalDateTime/parse "2019-12-18T16:01:41.485")
(java.time.format.DateTimeFormatter/ofLocalizedDateTime java.time.format.FormatStyle/SHORT)))]
(is (and (str/includes? out "12") (str/includes? out "18"))))


(is (number? (bb "
(let [x (java.time.LocalDateTime/parse \"2019-12-18T16:01:41.485\")
y (java.time.LocalDateTime/now)]
Expand Down

0 comments on commit ead237e

Please sign in to comment.