diff --git a/src/@dates/double.m b/src/@dates/double.m index dd9bd959336d0c8355b4cc6574cec7838a1d4cf9..f1fbe0c8faf32fa936f4e652b53e67062eebe2df 100644 --- a/src/@dates/double.m +++ b/src/@dates/double.m @@ -33,10 +33,14 @@ if o.freq==365 % Would need to find a way to deal with leap years end -years = floor((o.time-1)/o.freq); -subperiods = o.time-years*o.freq; +if o.freq == 1 + m = o.time; +else + years = floor((o.time-1)/o.freq); + subperiods = o.time-years*o.freq; + m = years+(subperiods-1)/o.freq; +end -m = years+(subperiods-1)/o.freq; if nargout>1 f = o.freq; end @@ -82,4 +86,24 @@ if t(1) t(2) = isequal(C,E); end T = all(t); -%@eof:2 \ No newline at end of file +%@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