View Source Rivet.Utils.Time (rivet_utils v1.1.5)
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
start_datetime_of_posix_interval/4.
utc_hours_since_midnight_sunday/0.
iex> utc_offset(:string) "-06:00" iex> utc_offset(:minutes) -360 iex> utc_offset(:hour_min) {-6, 0}
Link to this section 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:
: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
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.
@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.
iex> utc_offset(:string) "-06:00" iex> utc_offset(:minutes) -360 iex> utc_offset(:hour_min) {-6, 0}