Commit 4f7606f5 authored by MichelJuillard's avatar MichelJuillard
Browse files

* matlab/@dynDate: started changing references to dynTime by

  dynDates; dynDate can be initialized with a single dynDate
parent 15fa7fc8
...@@ -4,7 +4,7 @@ function sp = colon(a,b) ...@@ -4,7 +4,7 @@ function sp = colon(a,b)
%! @deftypefn {Function File} {@var{sp} =} colon (@var{a},@var{b}) %! @deftypefn {Function File} {@var{sp} =} colon (@var{a},@var{b})
%! @anchor{@dynDate/colon} %! @anchor{@dynDate/colon}
%! @sp 1 %! @sp 1
%! Overloads the colon operator for the Dynare Dates class (@ref{dynDate}). Creates a @ref{dynTime} object. %! Overloads the colon operator for the Dynare Dates class (@ref{dynDate}). Creates a @ref{dynDates} object.
%! @sp 2 %! @sp 2
%! @strong{Inputs} %! @strong{Inputs}
%! @sp 1 %! @sp 1
...@@ -19,13 +19,13 @@ function sp = colon(a,b) ...@@ -19,13 +19,13 @@ function sp = colon(a,b)
%! @sp 1 %! @sp 1
%! @table @ @var %! @table @ @var
%! @item c %! @item c
%! Dynare Time object instantiated by @ref{dynTime}. %! Dynare Dates object instantiated by @ref{dynDates}.
%! @end table %! @end table
%! @sp 2 %! @sp 2
%! @strong{This function is called by:} %! @strong{This function is called by:}
%! @sp 2 %! @sp 2
%! @strong{This function calls:} %! @strong{This function calls:}
%! @ref{dynTime}, @ref{@@dynTime/setFreq}, @ref{@@dynTime/setTime}, @ref{@@dynTime/setSize} %! @ref{dynDates}, @ref{@@dynDates/setFreq}, @ref{@@dynDates/setTime}, @ref{@@dynDates/setSize}
%! %!
%! @end deftypefn %! @end deftypefn
%@eod: %@eod:
...@@ -50,7 +50,7 @@ function sp = colon(a,b) ...@@ -50,7 +50,7 @@ function sp = colon(a,b)
% Original author: stephane DOT adjemian AT univ DASH lemans DOT fr % Original author: stephane DOT adjemian AT univ DASH lemans DOT fr
if nargin~=2 if nargin~=2
error('dynTime::colon: I need exactly two input arguments!') error('dynDate::colon: I need exactly two input arguments!')
end end
if ~( isa(a,'dynDate') && isa(b,'dynDate')) if ~( isa(a,'dynDate') && isa(b,'dynDate'))
...@@ -65,22 +65,28 @@ if a>b ...@@ -65,22 +65,28 @@ if a>b
error(['dynDate::colon: ' inputname(1) ' must precede ' inputname(2) '!' ]) error(['dynDate::colon: ' inputname(1) ' must precede ' inputname(2) '!' ])
end end
if a==b% Time range with only one date. sp = dynDates(a);
sp = dynTime(); n = b-a;
sp = sp.setFreq(a.freq); for t=1:n
sp = sp.setSize(1); a = +a;
sp = sp.setTime(1,a.time); sp = sp.append(a);
else
n = b-a;
sp = dynTime();
sp = sp.setFreq(a.freq);
sp = sp.setSize(n+1);
sp = sp.setTime(1,a.time);
for t=2:n+1
a = +a;
sp = sp.setTime(t,a.time);
end
end end
% $$$ if a==b% Time range with only one date.
% $$$ sp = dynDates(a);
% $$$ sp = sp.setFreq(a.freq);
% $$$ sp = sp.setSize(1);
% $$$ sp = sp.setTime(1,a.time);
% $$$ else
% $$$ n = b-a;
% $$$ sp = dynDates();
% $$$ sp = sp.setFreq(a.freq);
% $$$ sp = sp.setSize(n+1);
% $$$ sp = sp.setTime(1,a.time);
% $$$ for t=2:n+1
% $$$ a = +a;
% $$$ sp = sp.setTime(t,a.time);
% $$$ end
% $$$ end
%@test:1 %@test:1
%$ % Define two dates %$ % Define two dates
......
...@@ -66,9 +66,9 @@ function dd = dynDates(varargin) ...@@ -66,9 +66,9 @@ function dd = dynDates(varargin)
dd = struct; dd = struct;
dd.ndat = []; dd.ndat = 0;
dd.freq = []; dd.freq = [];
dd.time = dynTime(); dd.time = [];
dd = class(dd,'dynDates'); dd = class(dd,'dynDates');
...@@ -80,7 +80,7 @@ switch nargin ...@@ -80,7 +80,7 @@ switch nargin
if isa(varargin{1},'dynDates') if isa(varargin{1},'dynDates')
% Returns a copy of the input argument % Returns a copy of the input argument
dd = varargin{1}; dd = varargin{1};
elseif ischar(varargin{1}) elseif ischar(varargin{1}) || isa(varargin{1},'dynDate')
tmp = dynDate(varargin{1}); tmp = dynDate(varargin{1});
dd.ndat = 1; dd.ndat = 1;
dd.freq = tmp.freq; dd.freq = tmp.freq;
......
...@@ -92,6 +92,8 @@ if length(S)==1 && isequal(S.type,'.') ...@@ -92,6 +92,8 @@ if length(S)==1 && isequal(S.type,'.')
end end
if length(S)==1 && isequal(S.type,'()') if length(S)==1 && isequal(S.type,'()')
if isa(S.subs{1},'dynTime')
if ischar(S.subs{1}) if ischar(S.subs{1})
us = dynSeries(S.subs{1}); us = dynSeries(S.subs{1});
else else
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment