FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

#74: Lossy sql time conversion by frenchy64 · Pull Request #90 · dm3/clojure.java-time · GitHub

Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .clj  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
18 changes: 18 additions & 0 deletions test/java_time_test.clj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,17 @@
(java.sql.Timestamp. 1)
(j/instant->sql-timestamp (j/instant 1))
(j/instant->sql-timestamp 1)))

(is (= (let [^java.time.LocalTime t (j/with-clock clock (j/local-time))]
(java.sql.Time/valueOf t))
(j/with-clock clock (j/sql-time))
(j/sql-time (j/with-clock clock (j/local-time)))))
(is (= (java.sql.Time/valueOf (j/local-time 20))
(j/sql-time 20)
(j/sql-time (j/local-time 20))))
(is (= (java.sql.Time/valueOf (j/local-time 20 30))
(j/sql-time 20 30)
(j/sql-time (j/local-time 20 30))))
(is (= (java.sql.Time/valueOf (j/local-time 20 30 40))
(j/sql-time 20 30 40)
(j/sql-time (j/local-time 20 30 40))))
Expand Down Expand Up @@ -1100,3 +1111,10 @@
(is (= (j/zoned-date-time #inst "1970-01-01T00:00:00.100" "UTC")
(-> (j/instant 100)
(j/zoned-date-time "UTC")))))

(deftest sql-time-to-local-time-test
(is (= (j/local-time 1 12 13 456000000)
(j/local-time (j/sql-time (j/local-time 1 12 13 456000000)))))
(is (= (j/sql-time (j/local-time 1 12 13 456000000))
(let [millis-of-day (.get (j/local-time 1 12 13 456000000) java.time.temporal.ChronoField/MILLI_OF_DAY)]
(java.sql.Time. millis-of-day)))))

Back | FazBrowse Home | New Git URL