every v0.0.4 Every
Every gives you ability to use Process.send_after/3
with calculated intervals which can be rounded to every
(note: all functions return values only in seconds)
- Minute,
- N minutes,
- Hour,
- N Hours.
Every method accepts optional relative_to
parameter
if it is provided then duration in seconds until next
call will be calculated relative to given relative_to
.
Link to this section Summary
Functions
Calculate interval until next day
Calculate how many minutes left until next hour starts
Calculate how many minutes left until next hour starts
Calculate how many seconds left until next minute starts
Calculate how many minutes left until next interval
Link to this section Functions
Calculate interval until next day.
If relative_to
DateTime
is not provided
then current moment in time is used.
Returns: integer
number of seconds.
Example
iex> {:ok, now, _} = DateTime.from_iso8601("2018-10-14T16:48:12.000Z")
iex> Every.day(now)
25908
Calculate how many minutes left until next hour starts.
If relative_to
DateTime
is not provided
then current moment in time is used.
Returns: integer
number of seconds.
Example
iex> {:ok, now, _} = DateTime.from_iso8601("2018-10-14T16:48:12.000Z")
iex> Every.hour(now)
768
Calculate how many minutes left until next hour starts.
If relative_to
DateTime
is not provided
then current moment in time is used.
Returns: integer
number of seconds.
Example
iex> {:ok, now, _} = DateTime.from_iso8601("2018-10-14T16:48:12.000Z")
iex> Every.hour(now)
768
Calculate how many seconds left until next minute starts.
If relative_to
DateTime
is not provided
then current moment in time is used.
Returns: integer
number of seconds.
Example
iex> {:ok, now, _} = DateTime.from_iso8601("2018-10-14T16:48:12.000Z")
iex> Every.minute(now)
48
Calculate how many minutes left until next interval.
If relative_to
DateTime
is not provided
then current moment in time is used.
Returns: integer
number of seconds.
Example
iex> {:ok, now, _} = DateTime.from_iso8601("2018-10-14T16:48:12.000Z")
iex> Every.minutes(5, now) # 16:50 > 15:50:00 - 16:48:12
108