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