Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Configurable timestamp output format #181

@simpers

Description

@simpers

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions