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 state.ex
Raw

lib/repeating/state.ex

defmodule HumanTime.Repeating.State do
@moduledoc false
use GenServer
@spec start_link(any) :: {:error, any} | {:ok, pid}
def start_link(default) do
GenServer.start_link(__MODULE__, default)
end
@spec set(pid, any) :: no_return
def set(pid, new_state) do
GenServer.cast(pid, {:set, new_state})
end
@spec get(pid) :: any
def get(pid) do
GenServer.call(pid, :get)
end
# Server (callbacks)
@impl true
def init(stack) do
{:ok, stack}
end
@impl true
def handle_call(:get, _from, state) do
{:reply, state, state}
end
@impl true
def handle_cast({:set, new_state}, _state) do
{:noreply, new_state}
end
end