Dumballah v2.3.0 Dumballah.Calculate

Provides functions to perform time calculations.

Summary

Functions

Add :days, :hours and :minutes to a given timestamp

Calculates an Erlang date in Unix time from dawn

Calculates if a timestamp is in the past

Calculates the remaining seconds until midnight from an Erlang time

Subtract :days, :hours and :minutes from a given timestamp

Functions

add_time(current, unit, multiplier)

Specs

add_time(timestamp :: integer, unit :: atom, multiplier :: integer) :: timestamp :: integer

Add :days, :hours and :minutes to a given timestamp.

Examples

iex> Dumballah.Calculate.add_time(1474320734, :days, 1)
1474407134
date_from_dawn(arg)

Specs

date_from_dawn({year :: integer, month :: integer, day :: integer}) :: timestamp :: integer

Calculates an Erlang date in Unix time from dawn.

Examples

iex> Dumballah.Calculate.date_from_dawn({1995, 7, 3})
804729600
has_passed?(timestamp)

Specs

has_passed?(timestamp :: integer) :: has_passed? :: boolean

Calculates if a timestamp is in the past.

Examples

iex> Dumballah.Calculate.has_passed?(1474320734)
true
seconds_until_midnight(arg)

Specs

seconds_until_midnight({hours :: integer, minutes :: integer, seconds :: integer}) :: timestamp :: integer

Calculates the remaining seconds until midnight from an Erlang time.

Examples

iex> Dumballah.Calculate.seconds_until_midnight({3, 45, 0})
72900
subtract_time(current, unit, multiplier)

Specs

subtract_time(timestamp :: integer, unit :: atom, multiplier :: integer) :: timestamp :: integer

Subtract :days, :hours and :minutes from a given timestamp.

Examples

iex> Dumballah.Calculate.subtract_time(1474320734, :days, 1)
1474234334