Nebulex v2.0.0-rc.0 Nebulex.Time View Source

Time utilities.

Link to this section Summary

Functions

Returns the equivalent expiration time in milliseconds for the given time.

Returns the current system time in the given time unit.

Returns true if the given timeout is a valid timeout; otherwise, false is returned.

Link to this section Functions

Link to this function

do_expiry_time(time, atom)

View Source
Link to this function

expiry_time(time, unit \\ :second)

View Source

Specs

expiry_time(pos_integer(), :second | :minute | :hour | :day) :: pos_integer()

Returns the equivalent expiration time in milliseconds for the given time.

Example

iex> Nebulex.Time.expiry_time(10, :second)
10000

iex> Nebulex.Time.expiry_time(10, :minute)
600000

iex> Nebulex.Time.expiry_time(1, :hour)
3600000

iex> Nebulex.Time.expiry_time(1, :day)
86400000
Link to this function

now(unit \\ :millisecond)

View Source

Specs

Returns the current system time in the given time unit.

The unit is set to :millisecond by default.

Examples

iex> Nebulex.Time.now()
_milliseconds

Specs

timeout?(term()) :: boolean()

Returns true if the given timeout is a valid timeout; otherwise, false is returned.

Valid timeout: :infinity | non_neg_integer().

Examples

iex> Nebulex.Time.timeout?(1)
true

iex> Nebulex.Time.timeout?(:infinity)
true

iex> Nebulex.Time.timeout?(-1)
false