Cldr.Calendar.Duration.to_string

You're seeing just the function to_string, go back to Cldr.Calendar.Duration module for more information.
Link to this function

to_string(duration, options \\ [])

View Source

Returns a string formatted representation of a duration.

Note that time units that are zero are ommitted from the output.

Formatting is

Arguments

Options

Any other options are passed to Cldr.Number.to_string/3 and Cldr.Unit.to_string/3 during the formatting process.

Note

  • Any duration parts that are 0 are not output.

Example

iex> {:ok, duration} = Cldr.Calendar.Duration.new(~D[2019-01-01], ~D[2019-12-31])
iex> Cldr.Calendar.Duration.to_string(duration)
{:ok, "11 months and 30 days"}