Fork me on GitHub

for Java8 dates, I think they could be supported oob, as Jsonista does it for JSON and Java8 is required anyway, wrote:


PR would be welcome!

✌️ 4

@ikitommi thanks, I actually dug into the transit-clj implementation and it basically wraps around transit-java, which seems to hardcode a lot of mappings. Since transit is supposed to be extendable, should we be doing something like this?


not sure where "transit-dates/readers" is coming from in your docs


@kanwei exactly. The example was kinda bad, as the readers & writers were not explained. But those are the maps from the tutorial.


something like (joda example):

(ns metosin.transit.dates
  "Transit readers and writers for JodaTime and
  Supports two types:
  - DateTime (org.joda.time.DateTime,
  - LocalDate (org.joda.time.LocalDate,
  Represents DateTimes in RFC 3339 format: yyyy-mm-ddTHH:MM:SS.sssZ.
  RFC 3339 format is an specific profile of ISO 8601 DateTime format.
  Some consideration has been made to provide performant read
  implemenation for ClojureScript."
  (:require [cognitect.transit :as transit]
            [metosin.dates :as d]))

(def writers
  {#?(:clj org.joda.time.DateTime, :cljs
   (transit/write-handler (constantly "DateTime") d/to-string)

   #?(:clj org.joda.time.LocalDate, :cljs
   (transit/write-handler (constantly "Date") d/to-string)})

(def readers
  ; 1 argument arity version must be explicitly used for clojurescript
  {"DateTime" (transit/read-handler #(d/date-time %))
   "Date"     (transit/read-handler #(d/date %))})