Various optimizations and cosmetic changes.

time-shift
Stéphane Adjemian (Charybdis) 2014-05-15 12:31:53 +02:00
parent 35645540e5
commit b858aed1c0
7 changed files with 31 additions and 15 deletions

View File

@ -110,7 +110,7 @@ switch nargin
dd = subsref(dd,S);
return
else
error(['dates::dates: Wrong calling sequence!'])
error('dates::dates: Wrong calling sequence!')
end
for i=2:dd.ndat
if isdate(varargin{i})
@ -118,10 +118,10 @@ switch nargin
if isequal(date.freq,dd.freq)
dd.time(i,:) = date.time;
else
error(['dates::dates: Check that all the inputs have the same frequency (see input number ' str2num(i) ')!'])
error(sprintf('dates::dates: Check that all the inputs have the same frequency (see input number %i)!',i))
end
else
error(['dates::dates: Input ' str2num(i) ' has to be a string date!'])
error(sprintf('dates::dates: Input %i has to be a string date!',i))
end
end
end

View File

@ -93,7 +93,7 @@ switch S(1).type
elseif isequal(m,1)
B.time = [S(1).subs{2}, ones(n,1)];
else
error(['dates::subsref: This is a bug!'])
error('dates::subsref: This is a bug!')
end
B.ndat = rows(B.time);
elseif isequal(length(S(1).subs),3)
@ -148,7 +148,7 @@ switch S(1).type
elseif isequal(m,1) && isequal(B.freq,1)
B.time = [S(1).subs{1}, ones(n,1)];
else
error(['dates::subsref: This is a bug!'])
error('dates::subsref: This is a bug!')
end
B.ndat = rows(B.time);
else
@ -267,7 +267,7 @@ end
%$
%$ % Define a ranges of dates using qq.
%$ try
%$ r1 = qq(1950,1):qq([1950, 3]);
%$ r1 = qq(1950,1):qq(1950,3);%qq([1950, 3]);
%$ t(1) = 1;
%$ catch
%$ t(1) = 0;

View File

@ -25,11 +25,11 @@ function b = isdate(str) % --*-- Unitary tests --*--
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
if length(str)>1
%if length(str)>1
b = isquaterly(str) || isyearly(str) || ismonthly(str) || isweekly(str);
else
b = 0;
end
%else
%b = 0;
%end
%@test:1
%$

View File

@ -26,7 +26,11 @@ function b = ismonthly(str) % --*-- Unitary tests --*--
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
if ischar(str)
b = ~isempty(regexp(str,'^-?[0-9]*[Mm]([1-9]|1[0-2])$'));
if isempty(regexp(str,'^-?[0-9]*[Mm]([1-9]|1[0-2])$','once'))
b = 0;
else
b = 1;
end
else
b = 0;
end

View File

@ -25,8 +25,12 @@ function b = isquaterly(str) % --*-- Unitary tests --*--
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
if ischar(str)
b = ~isempty(regexp(str,'^-?[0-9]*[Qq][1-4]$'));
if ischar(str)
if isempty(regexp(str,'^-?[0-9]*[Qq][1-4]$','once'))
b = 0;
else
b = 1;
end
else
b = 0;
end

View File

@ -26,7 +26,11 @@ function b = isweekly(str) % --*-- Unitary tests --*--
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
if ischar(str)
b = ~isempty(regexp(str,'^-?[0-9]*[Ww]([1-9]|[1-4][0-9]|5[0-2])$'));
if isempty(regexp(str,'^-?[0-9]*[Ww]([1-9]|[1-4][0-9]|5[0-2])$','once'))
b = 0;
else
b = 1;
end
else
b = 0;
end

View File

@ -26,7 +26,11 @@ function b = isyearly(str) % --*-- Unitary tests --*--
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
if ischar(str)
b = ~isempty(regexp(str,'^-?[0-9]*[YyAa]$'));
if isempty(regexp(str,'^-?[0-9]*[YyAa]$','once'))
b = 0;
else
b = 1;
end
else
b = 0;
end