View Source Rivet.Utils.Time (rivet_utils v1.0.4)

Contributor: Brandon Gillespie

Link to this section Summary

Functions

this wraps the complexities brought on by Erlang being fancy with time, and gives us a conventional posix/epoch time value. The time value to return is specified by the first argument, as an atom, and is a required argument (to remove ambiguity), from the set

Iterate a map and merge string & atom keys into just atoms. Not recursive, only top level. Behavior with mixed keys being merged is not guaranteed, as maps are not always ordered.

utc_hours_since_midnight_sunday/0.

Link to this section Functions

Link to this function

epoch_time(time_type \\ :second)

View Source
@spec epoch_time(time_type :: atom()) :: integer()

this wraps the complexities brought on by Erlang being fancy with time, and gives us a conventional posix/epoch time value. The time value to return is specified by the first argument, as an atom, and is a required argument (to remove ambiguity), from the set:

:second, :millisecond, :microsecond or :nanosecond

It also uses their best value for 'monotonic' time so the clock will not go backwards.

For the full story see: https://hexdocs.pm/elixir/System.html http://erlang.org/doc/apps/erts/time_correction.html

Link to this function

iso_time_range(stime, etime)

View Source
Link to this function

start_datetime_of_posix_interval(datetime, interval, atom, num_of_intervals_back_or_forward)

View Source
@spec start_datetime_of_posix_interval(
  DateTime.t(),
  integer(),
  interval_unit :: :second | :millisecond,
  integer()
) :: DateTime.t()

start_datetime_of_posix_interval/4.

Suppose you have a DateTime that is 30 seconds past the beginning of a given minute. If the interval is 60_000 milliseconds (1 min.), then the beginning of the next posix interval is 30 seconds later- this returns that datetime.

Link to this function

time_at_today(input, reference)

View Source

Iterate a map and merge string & atom keys into just atoms. Not recursive, only top level. Behavior with mixed keys being merged is not guaranteed, as maps are not always ordered.

examples

Examples

iex> {:ok, %DateTime{}, %DateTime{}, elapsed} = time_range("20 min") iex> elapsed 1200

Link to this function

time_range(input, reference)

View Source
Link to this function

to_minutes(number, label)

View Source
Link to this function

utc_hours_since_midnight_sunday()

View Source
@spec utc_hours_since_midnight_sunday() :: 0..167

utc_hours_since_midnight_sunday/0.

There are 168 hours in a week, we zero-index them from 12:00:00 a.m. UTC Sunday.