View Source Euclid.Duration (Euclid v0.4.0)
A duration is a {time, unit}
tuple, where 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. Rounds down to the nearest whole number.
Uses System.convert_time_unit/3
under the hood; see its documentation for more details.
Converts a {duration, time_unit}
tuple into a string.
Link to this section Types
Specs
Specs
time_unit() :: :nanosecond | :microsecond | :millisecond | :second | :minute | :hour | :day
Link to this section Functions
Specs
Converts a {duration, time_unit}
tuple into a numeric duration. Rounds down to the nearest whole number.
Uses System.convert_time_unit/3
under the hood; see its documentation for more details.
Examples
iex> Euclid.Duration.convert({121, :second}, :minute)
2
Specs
Converts a {duration, time_unit}
tuple into a string.
Examples
iex> Euclid.Duration.to_string({1, :second})
"1 second"
iex> Euclid.Duration.to_string({25, :millisecond})
"25 milliseconds"