Skip to content

Commit 476d382

Browse files
committed
Fix #241 by fully-qualifying type hints
1 parent 1b63411 commit 476d382

File tree

5 files changed

+32
-28
lines changed

5 files changed

+32
-28
lines changed

ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## Changes Between 0.14.1 and 0.14.2
2+
3+
* Fully-qualify function return type hints to avoid requiring imports on use (#241).
4+
15
## Changes Between 0.14.0 and 0.14.1
26

37
* Switches `clojure.spec` to `clojure.spec.alpha` to work with latest Clojure 1.9 builds.

project.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(defproject clj-time/clj-time "0.14.1"
1+
(defproject clj-time/clj-time "0.14.2"
22
:description "A date and time library for Clojure, wrapping Joda Time."
33
:url "https://github.com/clj-time/clj-time"
44
:mailing-list {:name "clj-time mailing list"

src/clj_time/coerce.clj

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,42 +16,42 @@
1616
LocalDate LocalDateTime]))
1717

1818
(defprotocol ICoerce
19-
(to-date-time ^DateTime [obj] "Convert `obj` to a Joda DateTime instance."))
19+
(to-date-time ^org.joda.time.DateTime [obj] "Convert `obj` to a Joda DateTime instance."))
2020

21-
(defn ^DateTime from-long
21+
(defn ^org.joda.time.DateTime from-long
2222
"Returns a DateTime instance in the UTC time zone corresponding to the given
2323
number of milliseconds after the Unix epoch."
2424
[^Long millis]
2525
(DateTime. millis ^DateTimeZone utc))
2626

27-
(defn ^DateTime from-epoch
27+
(defn ^org.joda.time.DateTime from-epoch
2828
"Returns a DateTime instance in the UTC time zone
2929
from given Unix epoch."
3030
[^Long epoch]
3131
(from-long (* epoch 1000)))
3232

33-
(defn ^DateTime from-string
33+
(defn ^org.joda.time.DateTime from-string
3434
"return DateTime instance from string using
3535
formatters in clj-time.format, returning first
3636
which parses"
3737
[^String s]
3838
(time-fmt/parse s))
3939

40-
(defn ^DateTime from-date
40+
(defn ^org.joda.time.DateTime from-date
4141
"Returns a DateTime instance in the UTC time zone corresponding to the given
4242
Java Date object."
43-
[^Date date]
43+
[^java.util.Date date]
4444
(when date
4545
(from-long (.getTime date))))
4646

47-
(defn ^DateTime from-sql-date
47+
(defn ^org.joda.time.DateTime from-sql-date
4848
"Returns a DateTime instance in the UTC time zone corresponding to the given
4949
java.sql.Date object."
5050
[^java.sql.Date sql-date]
5151
(when sql-date
5252
(from-long (.getTime sql-date))))
5353

54-
(defn ^DateTime from-sql-time
54+
(defn ^org.joda.time.DateTime from-sql-time
5555
"Returns a DateTime instance in the UTC time zone corresponding to the given
5656
java.sql.Timestamp object."
5757
[^java.sql.Timestamp sql-time]
@@ -70,7 +70,7 @@
7070
(if-let [millis (to-long obj)]
7171
(quot millis 1000)))
7272

73-
(defn ^Date to-date
73+
(defn ^java.util.Date to-date
7474
"Convert `obj` to a Java Date instance."
7575
[obj]
7676
(if-let [dt (to-date-time obj)]
@@ -101,19 +101,19 @@
101101
(if-let [dt (to-date-time obj)]
102102
(java.sql.Timestamp. (.getMillis dt))))
103103

104-
(defn ^LocalDate to-local-date
104+
(defn ^org.joda.time.LocalDate to-local-date
105105
"Convert `obj` to a org.joda.time.LocalDate instance"
106106
[obj]
107107
(if-let [dt (to-date-time obj)]
108108
(LocalDate. (.getMillis (from-time-zone dt (default-time-zone))))))
109109

110-
(defn ^LocalDateTime to-local-date-time
110+
(defn ^org.joda.time.LocalDateTime to-local-date-time
111111
"Convert `obj` to a org.joda.time.LocalDateTime instance"
112112
[obj]
113113
(if-let [dt (to-date-time obj)]
114114
(LocalDateTime. (.getMillis (from-time-zone dt (default-time-zone))))))
115115

116-
(defn ^LocalDate in-time-zone
116+
(defn ^org.joda.time.LocalDate in-time-zone
117117
"Convert `obj` into `tz`, return org.joda.time.LocalDate instance."
118118
[obj tz]
119119
(if-let [dt (to-date-time obj)]

src/clj_time/core.clj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@
274274
([^DateTimeZone tz]
275275
(DateMidnight. tz)))
276276

277-
(defn ^DateTime with-time-at-start-of-day
277+
(defn ^org.joda.time.DateTime with-time-at-start-of-day
278278
"Returns a DateTime representing the start of the day. Normally midnight,
279279
but not always true, as in some time zones with daylight savings."
280280
[^DateTime dt]
@@ -307,7 +307,7 @@
307307
[dt & dts]
308308
(reduce #(if (after? %1 %2) %1 %2) dt dts))
309309

310-
(defn ^DateTime date-time
310+
(defn ^org.joda.time.DateTime date-time
311311
"Constructs and returns a new DateTime in UTC.
312312
Specify the year, month of year, day of month, hour of day, minute of hour,
313313
second of minute, and millisecond of second. Note that month and day are
@@ -741,7 +741,7 @@
741741
(plus (first-day-of-the-month dt)
742742
(days (- n 1)))))
743743

744-
(defn ^DateTime today-at
744+
(defn ^org.joda.time.DateTime today-at
745745
([^long hours ^long minutes ^long seconds ^long millis]
746746
(let [^MutableDateTime mdt (.toMutableDateTime ^DateTime (now))]
747747
(.toDateTime (doto mdt
@@ -767,7 +767,7 @@
767767
`(do-at* ~base-date-time
768768
(fn [] ~@body)))
769769

770-
(defn ^DateTime floor
770+
(defn ^org.joda.time.DateTime floor
771771
"Floors the given date-time dt to the given time unit dt-fn,
772772
e.g. (floor (now) hour) returns (now) for all units
773773
up to and including the hour"

src/clj_time/format.clj

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
(declare formatters)
3939
;; The formatters map and show-formatters idea are strait from chrono.
4040

41-
(defn ^DateTimeFormatter formatter
41+
(defn ^org.joda.time.format.DateTimeFormatter formatter
4242
"Returns a custom formatter for the given date-time pattern or keyword."
4343
([fmts]
4444
(formatter fmts utc))
@@ -56,32 +56,32 @@
5656
(.toFormatter)
5757
(.withZone dtz)))))
5858

59-
(defn ^DateTimeFormat formatter-local
59+
(defn ^org.joda.time.format.DateTimeFormat formatter-local
6060
"Returns a custom formatter with no time zone info."
6161
([^String fmt]
6262
(DateTimeFormat/forPattern fmt)))
6363

64-
(defn ^DateTimeFormatter with-chronology
64+
(defn ^org.joda.time.format.DateTimeFormatter with-chronology
6565
"Return a copy of a formatter that uses the given Chronology."
6666
[^DateTimeFormatter f ^Chronology c]
6767
(.withChronology f c))
6868

69-
(defn ^DateTimeFormatter with-locale
69+
(defn ^org.joda.time.format.DateTimeFormatter with-locale
7070
"Return a copy of a formatter that uses the given Locale."
7171
[^DateTimeFormatter f ^Locale l]
7272
(.withLocale f l))
7373

74-
(defn ^DateTimeFormatter with-pivot-year
74+
(defn ^org.joda.time.format.DateTimeFormatter with-pivot-year
7575
"Return a copy of a formatter that uses the given pivot year."
7676
[^DateTimeFormatter f ^Long pivot-year]
7777
(.withPivotYear f pivot-year))
7878

79-
(defn ^DateTimeFormatter with-zone
79+
(defn ^org.joda.time.format.DateTimeFormatter with-zone
8080
"Return a copy of a formatter that uses the given DateTimeZone."
8181
[^DateTimeFormatter f ^DateTimeZone dtz]
8282
(.withZone f dtz))
8383

84-
(defn ^DateTimeFormatter with-default-year
84+
(defn ^org.joda.time.format.DateTimeFormatter with-default-year
8585
"Return a copy of a formatter that uses the given default year."
8686
[^DateTimeFormatter f ^Integer default-year]
8787
(.withDefaultYear f default-year))
@@ -153,7 +153,7 @@
153153
(def ^{:private true} printers
154154
(difference (set (keys formatters)) parsers))
155155

156-
(defn ^DateTime parse
156+
(defn ^org.joda.time.DateTime parse
157157
"Returns a DateTime instance in the UTC time zone obtained by parsing the
158158
given string according to the given formatter."
159159
([^DateTimeFormatter fmt ^String s]
@@ -164,7 +164,7 @@
164164
:let [d (try (parse f s) (catch Exception _ nil))]
165165
:when d] d))))
166166

167-
(defn ^LocalDateTime parse-local
167+
(defn ^org.joda.time.LocalDateTime parse-local
168168
"Returns a LocalDateTime instance obtained by parsing the
169169
given string according to the given formatter."
170170
([^DateTimeFormatter fmt ^String s]
@@ -175,7 +175,7 @@
175175
:let [d (try (parse-local f s) (catch Exception _ nil))]
176176
:when d] d))))
177177

178-
(defn ^LocalDate parse-local-date
178+
(defn ^org.joda.time.LocalDate parse-local-date
179179
"Returns a LocalDate instance obtained by parsing the
180180
given string according to the given formatter."
181181
([^DateTimeFormatter fmt ^String s]
@@ -186,7 +186,7 @@
186186
:let [d (try (parse-local-date f s) (catch Exception _ nil))]
187187
:when d] d))))
188188

189-
(defn ^LocalTime parse-local-time
189+
(defn ^org.joda.time.LocalTime parse-local-time
190190
"Returns a LocalTime instance obtained by parsing the
191191
given string according to the given formatter."
192192
([^DateTimeFormatter fmt ^ String s]

0 commit comments

Comments
 (0)