Replaced instantiation of dynDate objects by instantiation of dates objects in load/csv_file_data (initial date of the dataset).

time-shift
Stéphane Adjemian (Charybdis) 2013-10-16 11:34:45 +02:00
parent c8d4949c52
commit c4667fedbb
1 changed files with 11 additions and 12 deletions

View File

@ -59,8 +59,8 @@ if ~( isequal(withnames,0) || isequal(withnames,1) )
end end
% Output initialization % Output initialization
freq = 1; freq = 1; % Default frequency is annual.
init = dynDate(1); init = dates(1,1); % Default initial date is year one.
varlist = []; varlist = [];
if ~exist('OCTAVE_VERSION') if ~exist('OCTAVE_VERSION')
% Under Matlab, save time by using importdata % Under Matlab, save time by using importdata
@ -70,11 +70,11 @@ if ~exist('OCTAVE_VERSION')
if size(A.textdata, 1) == 1 if size(A.textdata, 1) == 1
% year dates confused for data % year dates confused for data
varlist = A.textdata(1, 2:end); varlist = A.textdata(1, 2:end);
init = dynDate(A.data(1, 1)); init = dates([num2str(A.data(1, 1)) 'Y']);
data = A.data(:, 2:end); data = A.data(:, 2:end);
else else
varlist = A.textdata(1, 2:end); varlist = A.textdata(1, 2:end);
init = dynDate(strrep(A.textdata{2, 1}, 'Y', '')); init = dates(A.textdata{2, 1});
data = A.data; data = A.data;
end end
elseif withnames && ~withtime elseif withnames && ~withtime
@ -83,10 +83,10 @@ if ~exist('OCTAVE_VERSION')
elseif ~withnames && withtime elseif ~withnames && withtime
if ~isstruct(A) if ~isstruct(A)
% year dates confused for data % year dates confused for data
init = dynDate(A(1, 1)); init = dates([num2str(A.data(1, 1)) 'Y']);
data = A(:, 2:end); data = A(:, 2:end);
else else
init = dynDate(strrep(A.textdata{1, 1}, 'Y', '')); init = dates(A.textdata{1, 1});
data = A.data; data = A.data;
end end
else else
@ -171,14 +171,13 @@ C = comma_locations(1)-1;
if withtime if withtime
tmp = linee(B:C); tmp = linee(B:C);
% Check the dates formatting % Check the dates formatting
if ~(isyearly(tmp) || isquaterly(tmp) || ismonthly(tmp) || isweekly(tmp)) if isnumeric(tmp) && isint(tmp)
tmp = [num2str(tmp) 'Y'];
end
if isdate(tmp)
error('load_csv_file_data:: Formatting error. I can''t read the dates!') error('load_csv_file_data:: Formatting error. I can''t read the dates!')
end end
if isyearly(tmp)==2 init = dates(tmp);
% Remove the Y (gpm/iris date format) if necessary
tmp = tmp(1:end-1);
end
init = dynDate(tmp);
freq = init.freq; freq = init.freq;
first = 2; first = 2;
else else