seancorfield/clj-time — Issue #11: Generic Coercion
Author: ejackson
Created: 2012-02-11 09:17:34+00:00
State: open

Is a generic coercion a good idea ? For instance within coerce.clj, something like:

;; Single protocol that convert a value to a Joda value
(defprotocol JodaCoercible
(to-clj-time [x]))

(extend-protocol JodaCoercible
java.lang.String
(to-clj-time [x] (c/from-string x))
org.joda.time.DateTime
(to-clj-time [x] x)
java.lang.Long
(to-clj-time [x] (c/from-long x)))

and etc for Date or others.

I'd be happy to submit a patch / pull request if so