Elixir Date.diff / 2 - undefined or private
I am new to Elixir and trying to run some scripts from elixir documentation, testing the Date structure gave strange result because it Date.compare(~D[2016-04-16], ~D[2016-04-28])
returns: lt and when I try to run Date.diff(~D[2016-04-16], ~D[2016-04-28])
I get this error
(UndefinedFunctionError) function Date.diff/2 is undefined or private
(elixir) Date.diff(~D[2016-04-16], ~D[2016-04-28])
source to share
Date.compare
works correctly. :lt
is not an error code, but rather a symbol indicating the result of the comparison.
Any comparison between two dates will yield one of the following three characters:
-
:lt
- "Less than" -
:gt
- "More than" -
:eq
- "Equal"
If you need to get the difference in dates as the number of days (for example Date.diff
), you will need to upgrade to Elixir> 1.4.5.
source to share