Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable timestamp output format #181

Open
simpers opened this issue Oct 16, 2018 · 0 comments
Open

Configurable timestamp output format #181

simpers opened this issue Oct 16, 2018 · 0 comments

Comments

@simpers
Copy link

simpers commented Oct 16, 2018

We would need to be able to change the default output format for this timestamp. I have a fork of version 3.1 where I added a setting for this. I have not converted it to version 4 yet as I am not sure Phoenix supports it.

Is it possible to change the following line to something more like below?

Encoder.BitString.encode(@for.to_iso8601(value), options)

case Application.get_env(:poison, :datetime_formatter) do
  nil ->
    Poison.Encoder.BitString.encode(@for.to_iso8601(value), options)
  formatter ->
    Poison.Encoder.BitString.encode(formatter.format(value), options)
end

This would allow the consumer to override the datetime output format while still defaulting to the previous behaviour.

I have not found any other system-wide solution for making sure that all the datetimes we output have the same format. If you'd to make an exception, I guess you just have to format it to a string before you encode it, but this is for all timestamps present when encoding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant