Skip to content

Instantly share code, notes, and snippets.

@guedes
Created May 11, 2012 11:53
Show Gist options
  • Save guedes/2659192 to your computer and use it in GitHub Desktop.
Save guedes/2659192 to your computer and use it in GitHub Desktop.
import Elixir.Builtin, except: ["+": 2]
defmodule DateUtils do
def :+.(left, right) when is_tuple(left) do
seconds = Erlang.calendar.datetime_to_gregorian_seconds(left)
result = seconds + right
Erlang.calendar.gregorian_seconds_to_datetime(result)
end
# is this correct ?
def :+.(left, right) do
Elixir.Builtin.+(left, right)
end
def run do
date = { { 2011, 10, 12 }, { 0, 0, 0 } }
day = (24 * 60 * 60)
date + 2 * day
end
end
IO.inspect DateUtils.run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment