View Source Moar.Duration (Moar v1.4.0)
A duration is a {time, unit}
tuple.
The time is a number and the unit is one of:
:nanosecond
, :microsecond
, :millisecond
, :second
, :minute
, :hour
, :day
.
Link to this section Summary
Functions
Converts a {duration, time_unit}
tuple into a numeric duration, rounding down to the nearest whole number.
Converts a {duration, time_unit}
tuple into a string.
Link to this section Types
@type time_unit() ::
:nanosecond | :microsecond | :millisecond | :second | :minute | :hour | :day
Link to this section Functions
Converts a {duration, time_unit}
tuple into a numeric duration, rounding down to the nearest whole number.
Uses System.convert_time_unit/3
under the hood; see its documentation for more details.
iex> Moar.Duration.convert({121, :second}, :minute)
2
Converts a {duration, time_unit}
tuple into a string.
iex> Moar.Duration.to_string({1, :second})
"1 second"
iex> Moar.Duration.to_string({25, :millisecond})
"25 milliseconds"