diff --git a/src/@dates/dates.m b/src/@dates/dates.m index 09810da7473a285fb0f14a61eb2ddd5c98c93d7d..3b400f441e57066da3610e3ceaedcf9481d3ed16 100644 --- a/src/@dates/dates.m +++ b/src/@dates/dates.m @@ -228,9 +228,9 @@ end % classdef %@test:3 %$ % Define some dates %$ B1 = '1945H1'; -%$ B2 = '1950H2'; +%$ B2 = '1950S2'; %$ B3 = '1950h1'; -%$ B4 = '1953h2'; +%$ B4 = '1953s2'; %$ %$ % Define expected results. %$ e.time = [1945*2+1; 1950*2+2; 1950*2+1; 1953*2+2]; diff --git a/src/utilities/convert/date2string.m b/src/utilities/convert/date2string.m index 0d2b0ece4ced136cd89c2500bb6621c35b074696..f7e356ff94e1b714a046199dd5a96e991b0a6efd 100644 --- a/src/utilities/convert/date2string.m +++ b/src/utilities/convert/date2string.m @@ -124,7 +124,7 @@ catch end if t(1) - t(2) = isequal(str, '1938H2'); + t(2) = isequal(str, '1938S2'); end T = all(t); diff --git a/src/utilities/convert/freq2string.m b/src/utilities/convert/freq2string.m index 428b1a6050fe1fbbe325602d6c7b857069a5ba9e..acacaccb5c63c04783df5786cdd9c08c6225b731 100644 --- a/src/utilities/convert/freq2string.m +++ b/src/utilities/convert/freq2string.m @@ -4,9 +4,9 @@ function s = freq2string(freq) % --*-- Unitary tests --*-- % - freq [integer] scalar equal to 1, 2, 4, 12, or 365 (resp. annual, bi-annual, quaterly, monthly, or daily) % % OUTPUTS -% - s [char] scalar equal to Y, H, Q, M, or D (resp. annual, bi-annual, quaterly, monthly, or daily) +% - s [char] scalar equal to Y, S, Q, M, or D (resp. annual, bi-annual, quaterly, monthly, or daily) -% Copyright © 2013-2020 Dynare Team +% Copyright © 2013-2021 Dynare Team % % This file is part of Dynare. % @@ -27,7 +27,7 @@ switch freq case 1 s = 'Y'; case 2 - s = 'H'; + s = 'S'; case 4 s = 'Q'; case 12 @@ -54,7 +54,7 @@ end if t(1) t(2) = isequal(strY, 'Y'); - t(3) = isequal(strH, 'H'); + t(3) = isequal(strH, 'S'); t(4) = isequal(strQ, 'Q'); t(5) = isequal(strM, 'M'); t(6) = isequal(strD, 'D'); diff --git a/src/utilities/convert/string2date.m b/src/utilities/convert/string2date.m index 72a19eed910040ec9f6ac899a9f58c44e752eb05..078f210cc0224fb729d2a1318259c28872011e63 100644 --- a/src/utilities/convert/string2date.m +++ b/src/utilities/convert/string2date.m @@ -31,7 +31,7 @@ if isyearly(a) end if isbiannual(a) - period = cellfun(@str2double, strsplit(a, {'H','h'})); + period = cellfun(@str2double, strsplit(a, {'H','h','S','s'})); date.freq = 2; date.time = period(1)*2+period(2); return diff --git a/src/utilities/is/isbiannual.m b/src/utilities/is/isbiannual.m index 149d24718db689eb6fc056411e087a9b5bd78908..9df67516645e2be3e55a8d0bd8215a46a27ca03a 100644 --- a/src/utilities/is/isbiannual.m +++ b/src/utilities/is/isbiannual.m @@ -1,6 +1,6 @@ function b = isbiannual(str) % --*-- Unitary tests --*-- -% Tests if the input can be interpreted as a bi-annual date. +% Tests if the input can be interpreted as a bi-annual date (semester). % % INPUTS % o str string. @@ -8,7 +8,7 @@ function b = isbiannual(str) % --*-- Unitary tests --*-- % OUTPUTS % o b integer scalar, equal to 1 if str can be interpreted as a bi-annual date or 0 otherwise. -% Copyright (C) 2020 Dynare Team +% Copyright © 2021 Dynare Team % % This file is part of Dynare. % @@ -26,7 +26,7 @@ function b = isbiannual(str) % --*-- Unitary tests --*-- % along with Dynare. If not, see <http://www.gnu.org/licenses/>. if ischar(str) - if isempty(regexp(str,'^-?[0-9]+[Hh][1-2]$','once')) + if isempty(regexp(str,'^-?[0-9]+[HhSs][1-2]$','once')) b = false; else b = true; @@ -44,6 +44,8 @@ end %$ date_5 = '1950 azd '; %$ date_6 = '1950Y'; %$ date_7 = '1950m24'; +%$ date_8 = '1950S2'; +%$ date_9 = '1950s2'; %$ %$ t(1) = dassert(isbiannual(date_1),true); %$ t(2) = dassert(isbiannual(date_2),true); @@ -52,5 +54,7 @@ end %$ t(5) = dassert(isbiannual(date_5),false); %$ t(6) = dassert(isbiannual(date_6),false); %$ t(7) = dassert(isbiannual(date_7),false); +%$ t(8) = dassert(isbiannual(date_8),true); +%$ t(9) = dassert(isbiannual(date_9),true); %$ T = all(t); %@eof:1 \ No newline at end of file