Skip to content

Instantly share code, notes, and snippets.

View Jeweller-Tsai's full-sized avatar

nate Jeweller-Tsai

View GitHub Profile
def next %Date{year: y, month: m, day: d} do
case Date.new(y, m, d + 1) do
{:ok, nd} -> nd
{:error, _} ->
case Date.new(y, m + 1, 1) do
{:ok, nd} -> nd
{:error, _} ->
{:ok, nd} = Date.new(y + 1, 1, 1)
nd
end
defmodule ExclusiveDateRange do
defstruct first: nil, last: nil
def new(first, last) do
%ExclusiveDateRange{first: first, last: last}
end
defimpl Enumerable, for: ExclusiveDateRange do
def reduce _dr, {:halt, acc}, _fun do
defmodule DateRange do
defstruct first: nil, last: nil, first_gregorian_days: nil, last_greogorian_days: nil
defmodule Operator do
def first <~> last do
DateRange.new first, last
end
end
defmodule Node do
defstruct value: "", children: []
end