File tree Expand file tree Collapse file tree 2 files changed +29
-2
lines changed
src/lambdaisland/deep_diff
test/lambdaisland/deep_diff Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change 55 [puget.dispatch]
66 [puget.printer :as puget]
77 [arrangement.core]
8- [lambdaisland.deep-diff.diff :as diff]))
8+ [lambdaisland.deep-diff.diff :as diff])
9+ (:import (java.text SimpleDateFormat)
10+ (java.util TimeZone)))
911
1012(defn print-deletion [printer expr]
1113 (let [no-color (assoc printer :print-color false )]
3436 [:align (interpose [:span (:map-delimiter this) :line ] entries)]
3537 (color/document this :delimiter " }" )]))
3638
39+ (def ^:private thread-local-utc-date-format
40+ (proxy [ThreadLocal] []
41+ (initialValue []
42+ (doto (SimpleDateFormat. " yyyy-MM-dd'T'HH:mm:ss.SSS-00:00" )
43+ (.setTimeZone (TimeZone/getTimeZone " GMT" ))))))
44+
45+ (def ^:private print-date
46+ (puget/tagged-handler 'inst
47+ #(.format (.get thread-local-utc-date-format) %)))
48+
3749(def ^:private print-handlers
3850 {'lambdaisland.deep_diff.diff.Deletion
3951 print-deletion
7284 [:span
7385 (puget/format-doc printer k)
7486 (if (coll? v) (:map-coll-separator printer) " " )
75- (puget/format-doc printer v)]))))})
87+ (puget/format-doc printer v)]))))
88+
89+ 'java.util.Date
90+ print-date})
7691
7792(defn- print-handler-resolver [extra-handlers]
7893 (fn [^Class klz]
Original file line number Diff line number Diff line change 1+ (ns lambdaisland.deep-diff.printer-test
2+ (:require [clojure.test :refer :all ]
3+ [lambdaisland.deep-diff.diff :as diff]
4+ [lambdaisland.deep-diff.printer :as printer]))
5+
6+ (deftest print-doc-test
7+ (let [printer (printer/puget-printer {})]
8+ (is (= " [31m-#inst \" 2019-04-09T14:57:46.128-00:00\" [0m [32m+#inst \" 2019-04-10T14:57:46.128-00:00\" [0m\n "
9+ (with-out-str (-> (diff/diff #inst " 2019-04-09T14:57:46.128-00:00"
10+ #inst " 2019-04-10T14:57:46.128-00:00" )
11+ (printer/format-doc printer)
12+ (printer/print-doc printer)))))))
You can’t perform that action at this time.
0 commit comments