File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed
src/lambdaisland/deep_diff
test/lambdaisland/deep_diff Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 77 [arrangement.core]
88 [lambdaisland.deep-diff.diff :as diff])
99 (:import (java.text SimpleDateFormat)
10- (java.util TimeZone)))
10+ (java.util TimeZone)
11+ (java.sql Timestamp)))
1112
1213(defn print-deletion [printer expr]
1314 (let [no-color (assoc printer :print-color false )]
4748 'inst
4849 #(.format ^SimpleDateFormat (.get thread-local-utc-date-format) %)))
4950
51+ (def ^:private ^ThreadLocal thread-local-utc-timestamp-format
52+ (proxy [ThreadLocal] []
53+ (initialValue []
54+ (doto (SimpleDateFormat. " yyyy-MM-dd'T'HH:mm:ss" )
55+ (.setTimeZone (TimeZone/getTimeZone " GMT" ))))))
56+
57+ (def ^:private print-timestamp
58+ (puget/tagged-handler
59+ 'inst
60+ #(str (.format ^SimpleDateFormat (.get thread-local-utc-timestamp-format) %)
61+ (format " .%09d-00:00" (.getNanos ^Timestamp %)))))
62+
5063(def ^:private print-handlers
5164 {'lambdaisland.deep_diff.diff.Deletion
5265 print-deletion
90103 'java.util.Date
91104 print-date
92105
106+ 'java.sql.Timestamp
107+ print-timestamp
108+
93109 'java.util.UUID
94110 (puget/tagged-handler 'uuid str)})
95111
Original file line number Diff line number Diff line change 11(ns lambdaisland.deep-diff.printer-test
22 (:require [clojure.test :refer :all ]
33 [lambdaisland.deep-diff.diff :as diff]
4- [lambdaisland.deep-diff.printer :as printer]))
4+ [lambdaisland.deep-diff.printer :as printer])
5+ (:import (java.sql Timestamp)))
56
67(defn- printed
78 [diff]
1516 (is (= " \u 001B[31m-#inst \" 2019-04-09T14:57:46.128-00:00\"\u 001B[0m \u 001B[32m+#inst \" 2019-04-10T14:57:46.128-00:00\"\u 001B[0m\n "
1617 (printed (diff/diff #inst " 2019-04-09T14:57:46.128-00:00"
1718 #inst " 2019-04-10T14:57:46.128-00:00" )))))
19+
20+ (testing " timestamp"
21+ (is (= " \u 001B[31m-#inst \" 1970-01-01T00:00:00.000000000-00:00\"\u 001B[0m \u 001B[32m+#inst \" 1970-01-01T00:00:01.000000101-00:00\"\u 001B[0m\n "
22+ (printed (diff/diff (Timestamp. 0 )
23+ (doto (Timestamp. 1000 ) (.setNanos 101 )))))))
24+
1825 (testing " uuid"
1926 (is (= " \u 001B[31m-#uuid \" e41b325a-ce9d-4fdd-b51d-280d9c91314d\"\u 001B[0m \u 001B[32m+#uuid \" 0400be9a-619f-4c6a-a735-6245e4955995\"\u 001B[0m\n "
2027 (printed (diff/diff #uuid " e41b325a-ce9d-4fdd-b51d-280d9c91314d"
You can’t perform that action at this time.
0 commit comments