Skip to content

Commit

Permalink
core: allow diff between Date and DateTime.
Browse files Browse the repository at this point in the history
  • Loading branch information
mworrell committed Jun 30, 2015
1 parent 08300d9 commit 80c9fb0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/support/z_datetime.erl
Expand Up @@ -405,6 +405,10 @@ days_in_year(Y) ->
end.

%% @doc Return the absolute difference between two dates. Does not take daylight saving into account.
diff({Y,M,D}, Date2) when is_integer(Y), is_integer(M), is_integer(D) ->
diff({{Y,M,D},{0,0,0}}, Date2);
diff(Date1, {Y,M,D}) when is_integer(Y), is_integer(M), is_integer(D) ->
diff(Date1, {{Y,M,D},{0,0,0}});
diff(Date1, Date2) when Date1 < Date2 ->
diff(Date2,Date1);
diff({YMD1,{H1,I1,S1}}, {_,{_,_,S2}} = Date2) when S2 > S1 ->
Expand Down

0 comments on commit 80c9fb0

Please sign in to comment.