Skip to content

Commit 449ed51

Browse files
committed
more bb support
1 parent 4d5b6bb commit 449ed51

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

src/java_time.cljc

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
(let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.pre-java8/sql-date))))] (defn sql-date {:doc "Creates a `java.sql.Date` out of any combination of arguments valid for\n `java-time/local-date` or the `LocalDate` itself.\n\n Please consider using the JSR-310 Java Time types instead of `java.sql.Date`\n if your drivers support them.\n\n Even though `java.sql.Date` extends a `java.util.Date`, it's supposed to be\n used as a local date (no time component or timezone) for the purposes of\n conversion from/to native JDBC driver DATE types.", :tag java.sql.Date} ([] ((deref +impl+))) ([G__0] ((deref +impl+) G__0)) ([G__0 G__1] ((deref +impl+) G__0 G__1)) ([G__0 G__1 G__2] ((deref +impl+) G__0 G__1 G__2))))
124124
(let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.pre-java8/sql-timestamp))))] (defn sql-timestamp {:doc "Creates a `java.sql.Timestamp` in the local timezone out of any combination\n of arguments valid for `java-time/local-date-time` or the `LocalDateTime`\n itself.\n\n The `sql-timestamp` constructor function does not support `Timestamp`\n construction from an `Instant` or a long millis value. Please use\n `instant->sql-timestamp` for this purpose.\n\n Please consider using the JSR-310 Java Time types instead of\n `java.sql.Timestamp` if your drivers support them.\n\n `java.sql.Timestamp` is a version of a `java.util.Date` supposed to be used\n as a local date-time (no timezone) for the purposes of conversion from/to native\n JDBC driver TIMESTAMP types.", :tag java.sql.Timestamp} ([] ((deref +impl+))) ([G__0] ((deref +impl+) G__0)) ([G__0 G__1] ((deref +impl+) G__0 G__1)) ([G__0 G__1 G__2] ((deref +impl+) G__0 G__1 G__2)) ([G__0 G__1 G__2 G__3] ((deref +impl+) G__0 G__1 G__2 G__3)) ([G__0 G__1 G__2 G__3 G__4] ((deref +impl+) G__0 G__1 G__2 G__3 G__4)) ([G__0 G__1 G__2 G__3 G__4 G__5] ((deref +impl+) G__0 G__1 G__2 G__3 G__4 G__5)) ([G__0 G__1 G__2 G__3 G__4 G__5 G__6] ((deref +impl+) G__0 G__1 G__2 G__3 G__4 G__5 G__6))))
125125
(let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.pre-java8/instant->sql-timestamp))))] (defn instant->sql-timestamp {:doc "Creates a `java.sql.Timestamp` from the provided `instant-or-millis` - a\n millisecond numeric time value or something convertible to an `Instant`.\n\n Please consider using the JSR-310 Java Time types instead of\n `java.sql.Timestamp` if your drivers support them.\n\n `java.sql.Timestamp` is a version of a `java.util.Date` supposed to be used\n as a local date-time (no timezone) for the purposes of conversion from/to native\n JDBC driver TIMESTAMP types."} [instant-or-millis] ((deref +impl+) instant-or-millis)))
126-
(let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.pre-java8/sql-time))))] (defn sql-time {:doc "Creates a `java.sql.Time` out of any combination of arguments valid for\n `java-time/local-time` (except the nanos constructor) or the `LocalTime`\n itself.\n\n Please consider using the JSR-310 Java Time types instead of `java.sql.Time`\n if your drivers support them.\n\n Even though `java.sql.Time` extends a `java.util.Date`, it's supposed to be\n used as a local time (no date component or timezone) for the purposes of\n conversion from/to native JDBC driver TIME types.", :tag java.sql.Time} ([] ((deref +impl+))) ([G__0] ((deref +impl+) G__0)) ([G__0 G__1] ((deref +impl+) G__0 G__1)) ([G__0 G__1 G__2] ((deref +impl+) G__0 G__1 G__2))))
126+
(java-time.util/when-class "java.sql.Time" (let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.pre-java8/sql-time))))] (defn sql-time {:doc "Creates a `java.sql.Time` out of any combination of arguments valid for\n `java-time/local-time` (except the nanos constructor) or the `LocalTime`\n itself.\n\n Please consider using the JSR-310 Java Time types instead of `java.sql.Time`\n if your drivers support them.\n\n Even though `java.sql.Time` extends a `java.util.Date`, it's supposed to be\n used as a local time (no date component or timezone) for the purposes of\n conversion from/to native JDBC driver TIME types.", :tag java.sql.Time} ([] ((deref +impl+))) ([G__0] ((deref +impl+) G__0)) ([G__0 G__1] ((deref +impl+) G__0 G__1)) ([G__0 G__1 G__2] ((deref +impl+) G__0 G__1 G__2)))))
127127
(let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.interval/move-start-to))))] (defn move-start-to {:doc "Moves the start instant of the interval to the given instant (or something\n convertible to an instant):\n\n (move-start-to (interval 0 10000) (instant 5000))\n => #<Interval ...:05Z/...:10Z>\n\n Fails if the new start instant falls after the end instant:\n\n (move-start-to (interval 0 10000) (millis 15000))\n => DateTimeException..."} [i new-start] ((deref +impl+) i new-start)))
128128
(let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.interval/move-end-to))))] (defn move-end-to {:doc "Moves the end of the interval to the given instant (or something\n convertible to an instant):\n\n (move-end-to (interval 0 10000) (instant 15000))\n => #<Interval ...:00Z/...:15Z>\n\n Fails if the new end instant falls before the start instant:\n\n (move-end-to (interval 0 10000) (millis -1))\n => DateTimeException..."} [i new-end] ((deref +impl+) i new-end)))
129129
(let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.interval/move-start-by))))] (defn move-start-by {:doc "Moves the start instant of the interval by the sum of given\n periods/durations/numbers of milliseconds:\n\n (move-start-by (interval 0 10000) (millis 1000) (seconds 1))\n => #<Interval ...:02Z/...:10Z>\n\n Fails if the new start instant falls after the end instant.\n\n (move-start-by (interval 0 10000) (millis 11000))\n ; => DateTimeException..."} [i & os] (apply (deref +impl+) i os)))

test/java_time/dev/gen.clj

+25-20
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,29 @@
2929
n (:name m)
3030
arglists (:arglists m)
3131
protocol (:protocol m)
32+
when-class (-> sym meta :when-class)
3233
forward-meta (into (sorted-map) (select-keys m [:doc :tag :deprecated]))
3334
forward-meta (cond-> forward-meta
3435
(nil? (:tag forward-meta)) (dissoc :tag))
3536
_ (assert (not= n impl-local-sym))]
3637
(when (:macro m)
3738
(throw (IllegalArgumentException.
3839
(str "Calling import-fn on a macro: " sym))))
39-
(list 'let [impl-local-sym (list 'delay
40-
(list 'load-java-time)
41-
(list 'deref (list 'resolve (list 'quote sym))))]
42-
(list* 'defn n
43-
(concat
44-
(some-> (not-empty forward-meta) list)
45-
(normalize-arities
46-
(map (fn [argv]
47-
(let [argv (normalize-argv argv)]
48-
(list argv
49-
(if (some #{'&} argv)
50-
(list* 'apply (list 'deref impl-local-sym) (remove #{'&} argv))
51-
(list* (list 'deref impl-local-sym) argv)))))
52-
arglists)))))))
40+
(cond->> (list 'let [impl-local-sym (list 'delay
41+
(list 'load-java-time)
42+
(list 'deref (list 'resolve (list 'quote sym))))]
43+
(list* 'defn n
44+
(concat
45+
(some-> (not-empty forward-meta) list)
46+
(normalize-arities
47+
(map (fn [argv]
48+
(let [argv (normalize-argv argv)]
49+
(list argv
50+
(if (some #{'&} argv)
51+
(list* 'apply (list 'deref impl-local-sym) (remove #{'&} argv))
52+
(list* (list 'deref impl-local-sym) argv)))))
53+
arglists)))))
54+
when-class (list 'java-time.util/when-class when-class))))
5355

5456
(defn import-macro [sym]
5557
(let [vr (find-var sym)
@@ -81,11 +83,13 @@
8183
rest
8284
(mapcat unravel)
8385
(map
84-
#(symbol
85-
(str (first x)
86-
(when-let [n (namespace %)]
87-
(str "." n)))
88-
(name %))))
86+
#(with-meta
87+
(symbol
88+
(str (first x)
89+
(when-let [n (namespace %)]
90+
(str "." n)))
91+
(name %))
92+
(meta %))))
8993
[x]))
9094
syms (mapcat unravel syms)]
9195
(map (fn [sym]
@@ -159,7 +163,8 @@
159163

160164
'[java-time.format format formatter]
161165

162-
'[java-time.pre-java8 java-date sql-date sql-timestamp instant->sql-timestamp sql-time]
166+
'[java-time.pre-java8 java-date sql-date sql-timestamp instant->sql-timestamp
167+
^{:when-class "java.sql.Time"} sql-time]
163168

164169
'[java-time.interval
165170
move-start-to move-end-to move-start-by move-end-by

0 commit comments

Comments
 (0)