Skip to content

Instantly share code, notes, and snippets.

@pollingj
Forked from arjan/timex_date_json.ex
Created April 6, 2016 15:09
Show Gist options
  • Save pollingj/b68ccff639be7c3e67d45812620b21a1 to your computer and use it in GitHub Desktop.
Save pollingj/b68ccff639be7c3e67d45812620b21a1 to your computer and use it in GitHub Desktop.
Automatically encode Timex datetimes as ISO in JSON
defimpl Poison.Encoder, for: Timex.DateTime do
use Timex
def encode(d, _options) do
fmt = Timex.format!(d, "{ISO}")
"\"#{fmt}\""
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment