Created
May 11, 2012 11:53
-
-
Save guedes/2659192 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
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