timex v2.0.0 Timex.Format.Time.Formatter behaviour

This module defines the behaviour for custom Time formatters

Summary

Functions

Formats a Time tuple/Erlang timestamp, as a string, using the provided formatter. If a formatter is not provided, the formatter used is Timex.Format.Time.Formatters.Default. As a handy shortcut, you can reference the other built-in formatter (Humanized) via the :humanized atom as shown below

Functions

format(timestamp, formatter \\ Default)

Specs

format(Types.timestamp, atom) ::
  String.t |
  {:error, term}

Formats a Time tuple/Erlang timestamp, as a string, using the provided formatter. If a formatter is not provided, the formatter used is Timex.Format.Time.Formatters.Default. As a handy shortcut, you can reference the other built-in formatter (Humanized) via the :humanized atom as shown below.

Examples

iex> Elixir.Timex.Format.Time.Formatter.format({1435, 180354, 590264})
"P45Y6M5DT21H12M34.590264S"
iex> Elixir.Timex.Format.Time.Formatter.format({1435, 180354, 590264}, :humanized)
"45 years, 6 months, 5 days, 21 hours, 12 minutes, 34 seconds, 590.264 milliseconds"

Callbacks

format(timestamp)

Specs

format(timestamp :: Types.timestamp) ::
  String.t |
  {:error, term}