diff --git a/src/edate.erl b/src/edate.erl index 89c3eb1..7ef27bc 100644 --- a/src/edate.erl +++ b/src/edate.erl @@ -31,7 +31,8 @@ subtract/2, today/0, tomorrow/0, - yesterday/0]). + yesterday/0, + is_valid/1]). -ifdef(TEST). -include_lib("eunit/include/eunit.hrl"). -endif. @@ -209,6 +210,12 @@ find_valid_date(Date) -> find_valid_date({Y, M, D-1}) end. +%% @spec is_valid(date()) -> boolean() +%% @doc Returns true if date is valid; otherwise false. +-spec is_valid(date()) -> boolean(). +is_valid(Date) -> + calendar:valid_date(Date). + %% @spec string_to_date(string()) -> date() %% @doc Converts `String' to a date. The following string formats are valid %% (with or without zero-padding):