Conduit v0.11.0 Conduit.Plug.CreatedAt View Source

Assigns a created_at date to the message.

A format can be specified. The default is "{ISO:Extended:Z}". The format can be anything that Timex.format/1 accepts. See here.

:unix_epoch may also be passed, which will set the timestamp to seconds since the UNIX epoch.

Examples

plug Conduit.Plug.CreatedAt
plug Conduit.Plug.CreatedAt, format: "{YYYY}-{M}-{D}"
plug Conduit.Plug.CreatedAt, format: :unix_epoch

iex> message = Conduit.Plug.CreatedAt.run(%Conduit.Message{}, format: "{ISO:Extended:Z}")
iex> # e.g. "2016-11-16T03:00:24.575904Z"
iex> {:ok, %DateTime{}} = Timex.parse(message.created_at, "{ISO:Extended:Z}")
iex> message = Conduit.Plug.CreatedAt.run(%Conduit.Message{}, format: :unix_epoch)
iex> # e.g. 1479265596
iex> is_integer(message.created_at)
true

Link to this section Summary

Functions

Assigns a ISO8601 timestamp to the message

Callback implementation for Conduit.Plug.init/1

Callback implementation for Conduit.Plug.run/2

Link to this section Functions

Link to this function call(message, next, format) View Source

Assigns a ISO8601 timestamp to the message.

Callback implementation for Conduit.Plug.init/1.

Link to this function run(message, opts \\ []) View Source

Callback implementation for Conduit.Plug.run/2.