From 743fe9faa76dace5e6670d2c24ac2722caeeb18a Mon Sep 17 00:00:00 2001 From: Stuart Thackray Date: Fri, 22 Apr 2016 13:21:14 +0200 Subject: [PATCH] add is valid function to the library --- src/edate.erl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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):