diff --git a/src/clojure/monger/joda_time.clj b/src/clojure/monger/joda_time.clj index f60e772..e26ec6f 100644 --- a/src/clojure/monger/joda_time.clj +++ b/src/clojure/monger/joda_time.clj @@ -27,3 +27,25 @@ java.util.Date (from-db-object [^java.util.Date input keywordize] (org.joda.time.DateTime. input))) + + + +;; +;; Reader extensions +;; + +(defmethod print-dup java.util.Date + [d out] + (.write out + (str "#=" + `(java.util.Date. ~(.getYear d) + ~(.getMonth d) + ~(.getDate d) + ~(.getHours d) + ~(.getMinutes d) + ~(.getSeconds d))))) + + +(defmethod print-dup org.joda.time.base.AbstractInstant + [d out] + (print-dup (.toDate d) out)) diff --git a/test/monger/test/lib_integration_test.clj b/test/monger/test/lib_integration_test.clj index 58e17f2..c402a47 100644 --- a/test/monger/test/lib_integration_test.clj +++ b/test/monger/test/lib_integration_test.clj @@ -34,3 +34,9 @@ output (from-db-object input false)] (is (instance? org.joda.time.DateTime output)) (is (= input (.toDate ^DateTime output))))) + + +(deftest test-reader-extensions + (let [^DateTime d (t/date-time 2011 10 13 23 55 0)] + (binding [*print-dup* true] + (pr-str d))))