Skip to content
Snippets Groups Projects
Verified Commit bd31aec3 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Fix double() method for dates at yearly frequency

Closes: #47
parent 4b2b014a
No related branches found
No related tags found
No related merge requests found
Pipeline #5240 passed
...@@ -33,10 +33,14 @@ if o.freq==365 ...@@ -33,10 +33,14 @@ if o.freq==365
% Would need to find a way to deal with leap years % Would need to find a way to deal with leap years
end end
if o.freq == 1
m = o.time;
else
years = floor((o.time-1)/o.freq); years = floor((o.time-1)/o.freq);
subperiods = o.time-years*o.freq; subperiods = o.time-years*o.freq;
m = years+(subperiods-1)/o.freq; m = years+(subperiods-1)/o.freq;
end
if nargout>1 if nargout>1
f = o.freq; f = o.freq;
end end
...@@ -83,3 +87,23 @@ if t(1) ...@@ -83,3 +87,23 @@ if t(1)
end end
T = all(t); T = all(t);
%@eof:2 %@eof:2
%@test:3
% Regression test for dseries#47
B = dates('1950Y'):dates('1952Y');
% Call the tested routine.
try
C = double(B);
t(1) = 1;
catch
t(1) = 0;
end
% Define expected results.
E = [1950; 1951; 1952];
if t(1)
t(2) = isequal(C,E);
end
T = all(t);
%@eof:3
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment