File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
src/lambdaisland/deep_diff
test/lambdaisland/deep_diff Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change 6060 #(str (.format ^SimpleDateFormat (.get thread-local-utc-timestamp-format) %)
6161 (format " .%09d-00:00" (.getNanos ^Timestamp %)))))
6262
63+ (def ^:private print-calendar
64+ (puget/tagged-handler
65+ 'inst
66+ #(let [formatted (format " %1$tFT%1$tT.%1$tL%1$tz" %)
67+ offset-minutes (- (.length formatted) 2 )]
68+ (str (subs formatted 0 offset-minutes)
69+ " :"
70+ (subs formatted offset-minutes)))))
71+
6372(def ^:private print-handlers
6473 {'lambdaisland.deep_diff.diff.Deletion
6574 print-deletion
103112 'java.util.Date
104113 print-date
105114
115+ 'java.util.GregorianCalendar
116+ print-calendar
117+
106118 'java.sql.Timestamp
107119 print-timestamp
108120
Original file line number Diff line number Diff line change 22 (:require [clojure.test :refer :all ]
33 [lambdaisland.deep-diff.diff :as diff]
44 [lambdaisland.deep-diff.printer :as printer])
5- (:import (java.sql Timestamp)))
5+ (:import (java.sql Timestamp)
6+ (java.util Date
7+ GregorianCalendar
8+ TimeZone)))
69
710(defn- printed
811 [diff]
1114 (printer/format-doc printer)
1215 (printer/print-doc printer)))))
1316
17+ (defn- calendar
18+ [date]
19+ (doto (GregorianCalendar. (TimeZone/getTimeZone " GMT" ))
20+ (.setTime date)))
21+
1422(deftest print-doc-test
1523 (testing " date"
1624 (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 "
2230 (printed (diff/diff (Timestamp. 0 )
2331 (doto (Timestamp. 1000 ) (.setNanos 101 )))))))
2432
33+ (testing " calendar"
34+ (is (= " \u 001B[31m-#inst \" 1970-01-01T00:00:00.000+00:00\"\u 001B[0m \u 001B[32m+#inst \" 1970-01-01T00:00:01.001+00:00\"\u 001B[0m\n "
35+ (printed (diff/diff (calendar (Date. 0 )) (calendar (Date. 1001 )))))))
36+
2537 (testing " uuid"
2638 (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 "
2739 (printed (diff/diff #uuid " e41b325a-ce9d-4fdd-b51d-280d9c91314d"
You can’t perform that action at this time.
0 commit comments