Closed joshrieken closed 8 years ago
Ah, yes this is due to the fact that Elixir's date/time types store microseconds as a tuple of {microseconds, precision}
. I would expect you would want to return timestamps in seconds since UNIX epoch when generating JSON though, no? I would use Timex.to_unix(transaction.inserted_at)
instead, otherwise you'll just get an object with fields like year
, month
, etc.
Ah, yes, that is a much better way. I'm not sure why I expected it to automatically do that. Thank you!
In my
web.ex
, I have:I have a function in my view for rendering JSON:
This view raises
(Poison.EncodeError) unable to encode value: {0, 0}
.When I remove
Timex.Ecto.Timestamps
fromweb.ex
, it renders as expected.