diff --git a/src/utilities/is/isdate.m b/src/utilities/is/isdate.m index 78ef73ccacc91ec30abc1b1317cb6339b37db38c..d9f805988ef8c23d8a140ea1dc6d5bd240f86af2 100644 --- a/src/utilities/is/isdate.m +++ b/src/utilities/is/isdate.m @@ -3,12 +3,12 @@ function b = isdate(str) % --*-- Unitary tests --*-- % Tests if the input string can be interpreted as a date. % % INPUTS -% o str string. +% - str [char] 1×m array, date (potentially) % % OUTPUTS -% o b integer scalar, equal to 1 if str can be interpreted as a date or 0 otherwise. +% - b [logical] scalar equal to true iff str can be interpreted as a date. -% Copyright (C) 2013-2017 Dynare Team +% Copyright © 2013-2020 Dynare Team % % This file is part of Dynare. % @@ -32,24 +32,29 @@ end b = isstringdate(str); +return + %@test:1 -%$ -%$ date_1 = 1950; -%$ date_2 = '1950m2'; -%$ date_3 = '-1950m2'; -%$ date_4 = '1950m52'; -%$ date_5 = ' 1950'; -%$ date_6 = '1950Y'; -%$ date_7 = '-1950a'; -%$ date_8 = '1950m '; -%$ -%$ t(1) = dassert(isdate(date_1),true); -%$ t(2) = dassert(isdate(date_2),true); -%$ t(3) = dassert(isdate(date_3),true); -%$ t(4) = dassert(isdate(date_4),false); -%$ t(5) = dassert(isdate(date_5),false); -%$ t(6) = dassert(isdate(date_6),true); -%$ t(7) = dassert(isdate(date_7),true); -%$ t(8) = dassert(isdate(date_8),false); -%$ T = all(t); +date_1 = 1950; +date_2 = '1950m2'; +date_3 = '-1950m2'; +date_4 = '1950m52'; +date_5 = ' 1950'; +date_6 = '1950Y'; +date_7 = '-1950a'; +date_8 = '1950m '; +date_9 = '2000-01-01'; +date_10 = '2000-02-30'; + +t(1) = isequal(isdate(date_1), true); +t(2) = isequal(isdate(date_2), true); +t(3) = isequal(isdate(date_3), true); +t(4) = isequal(isdate(date_4), false); +t(5) = isequal(isdate(date_5), false); +t(6) = isequal(isdate(date_6), true); +t(7) = isequal(isdate(date_7), true); +t(8) = isequal(isdate(date_8), false); +t(9) = isequal(isdate(date_9), true); +t(10) = isequal(isdate(date_10), false); +T = all(t); %@eof:1 \ No newline at end of file