From bd9414ae66e434441c3b55287429125e96af54ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= <stephane.adjemian@univ-lemans.fr> Date: Mon, 24 Oct 2016 12:09:12 +0200 Subject: [PATCH] Added two methods returning year and subperiod. --- src/@dates/subperiod.m | 20 ++++++++++++++++++++ src/@dates/subsref.m | 2 +- src/@dates/year.m | 20 ++++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/@dates/subperiod.m create mode 100644 src/@dates/year.m diff --git a/src/@dates/subperiod.m b/src/@dates/subperiod.m new file mode 100644 index 0000000..b85dd2d --- /dev/null +++ b/src/@dates/subperiod.m @@ -0,0 +1,20 @@ +function s = year(d) + +% Returns the subperiod (quarter, month or week depending on the frequency). + +% Copyright (C) 2016 Dynare Team +% +% This code is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare dates submodule is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +s = d.time(2); \ No newline at end of file diff --git a/src/@dates/subsref.m b/src/@dates/subsref.m index e961d70..627061f 100644 --- a/src/@dates/subsref.m +++ b/src/@dates/subsref.m @@ -36,7 +36,7 @@ switch S(1).type error(['dates::subsref: ' S(1).subs ' is not a method but a member!']) end B = builtin('subsref', A, S(1)); - case {'sort','sort_','unique','unique_','double','isempty','length','char','ndat'}% Public methods (without input arguments) + case {'sort','sort_','unique','unique_','double','isempty','length','char','ndat','year','subperiod'}% Public methods (without input arguments) B = feval(S(1).subs,A); if length(S)>1 && isequal(S(2).type,'()') && isempty(S(2).subs) S = shiftS(S,1); diff --git a/src/@dates/year.m b/src/@dates/year.m new file mode 100644 index 0000000..df2aad6 --- /dev/null +++ b/src/@dates/year.m @@ -0,0 +1,20 @@ +function y = year(d) + +% Returns the year. + +% Copyright (C) 2016 Dynare Team +% +% This code is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare dates submodule is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +y = d.time(1); \ No newline at end of file -- GitLab