Skip to content

Instantly share code, notes, and snippets.

@olivermt
Created January 26, 2017 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olivermt/8a9e99b58262357767d1e9a5b7109b49 to your computer and use it in GitHub Desktop.
Save olivermt/8a9e99b58262357767d1e9a5b7109b49 to your computer and use it in GitHub Desktop.
Ecto.Date.utc
|> Map.update(:year, nil, fn y -> y+1 end)
|> case do
in_a_year = %{month: 2, day: 29} ->
in_a_year = Map.update(:day, nil, fn y -> y-1 end)
put_change(changeset, :renewal_date, in_a_year)
in_a_year ->
put_change(changeset, :renewal_date, in_a_year)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment