Packages

Human Time is a function to convert a string such as "every other tuesday", "every weekday" or "every friday at 2pm" and convert it into a sequence of date times as allowed by the string.

Current section

Files

Jump to
human_time lib repeating generators.ex
Raw

lib/repeating/generators.ex

defmodule HumanTime.Repeating.Generators do
@moduledoc false
@spec seconds(DateTime.t) :: DateTime.t
def seconds(now), do: Timex.shift(now, seconds: 1)
@spec minutes(DateTime.t) :: DateTime.t
def minutes(now), do: Timex.shift(now, minutes: 1)
@spec hours(DateTime.t) :: DateTime.t
def hours(now), do: Timex.shift(now, hours: 1)
@spec days(DateTime.t) :: DateTime.t
def days(now), do: Timex.shift(now, days: 1)
# def while_function(nil), do: fn _ -> true end
@spec while_function(DateTime.t) :: fun
def while_function(until) do
fn v -> Timex.compare(v, until) != 1 end
end
end