Skip to content

Instantly share code, notes, and snippets.

@Jeweller-Tsai
Created August 6, 2016 08:42
Show Gist options
  • Save Jeweller-Tsai/726a909f5b0f3e017b8522ce9cc72eb2 to your computer and use it in GitHub Desktop.
Save Jeweller-Tsai/726a909f5b0f3e017b8522ce9cc72eb2 to your computer and use it in GitHub Desktop.
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
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment