This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Node do | |
defstruct value: "", children: [] | |
end |
OlderNewer