timex v3.0.5 Timex.Format.Duration.Formatters.Humanized

Handles formatting timestamp values as human readable strings. For formatting timestamps as points in time rather than intervals, use Timex.format

Summary

Functions

Return a human readable string representing the time interval

Return a human readable string representing the time interval, translated to the given locale

Functions

format(duration)

Specs

format(Timex.Duration.t) :: String.t | {:error, term}

Return a human readable string representing the time interval.

Examples

iex> alias Timex.Duration
iex> Duration.from_erl({1435, 180354, 590264}) |> Elixir.Timex.Format.Duration.Formatters.Humanized.format
"45 years, 6 months, 5 days, 21 hours, 12 minutes, 34 seconds, 590.264 milliseconds"
iex> Duration.from_erl({0, 65, 0}) |> Elixir.Timex.Format.Duration.Formatters.Humanized.format
"1 minute, 5 seconds"
lformat(duration, locale)

Specs

lformat(Timex.Duration.t, String.t) ::
  String.t |
  {:error, term}

Return a human readable string representing the time interval, translated to the given locale

Examples

iex> use Timex
...> Duration.from_erl({1435, 180354, 590264}) |> Elixir.Timex.Format.Duration.Formatters.Humanized.lformat("ru")
"45 года  6 месяца  5 днем  21 час  12 минуты  34 секунды  590.264 миллисекунды"

iex> use Timex
...> Duration.from_erl({0, 65, 0}) |> Elixir.Timex.Format.Duration.Formatters.Humanized.lformat("ru")
"1 минута  5 секунды"