Skip to content
Snippets Groups Projects
Verified Commit 54114116 authored by Stéphane Adjemian's avatar Stéphane Adjemian
Browse files

Use S instead of H for bi-annual dates.

H (half year) is still allowed.
parent d8c6c105
Branches
No related tags found
No related merge requests found
......@@ -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];
......
......@@ -124,7 +124,7 @@ catch
end
if t(1)
t(2) = isequal(str, '1938H2');
t(2) = isequal(str, '1938S2');
end
T = all(t);
......
......@@ -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');
......
......@@ -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
......
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment