From b3e8dbe018908aea869a004f8cab8b53b6f857f5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?=
 <stepan@adjemian.eu>
Date: Fri, 15 Jan 2021 20:42:21 +0100
Subject: [PATCH] Do not rely on internal representation of @dates, use methods
 instead...

... Or add a new method if one is missing.
---
 matlab/WriteShockDecomp2Excel.m   |  2 +-
 matlab/graph_decomp.m             |  2 +-
 matlab/graph_decomp_detail.m      |  2 +-
 matlab/modules/reporting          |  2 +-
 matlab/plot_shock_decomposition.m | 14 +++++++-------
 5 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/matlab/WriteShockDecomp2Excel.m b/matlab/WriteShockDecomp2Excel.m
index a111104558..7378115701 100644
--- a/matlab/WriteShockDecomp2Excel.m
+++ b/matlab/WriteShockDecomp2Excel.m
@@ -76,7 +76,7 @@ if isempty(initial_date)
     x = 1:gend;
 else
     freq = initial_date.freq;
-    initial_period = initial_date.time(1) + (initial_date.time(2)-1)/freq;
+    initial_period = double(initial_date);
     x = initial_period:(1/freq):initial_period+(gend-1)/freq;
 end
 
diff --git a/matlab/graph_decomp.m b/matlab/graph_decomp.m
index 5bf318bc84..60a0acb5d5 100644
--- a/matlab/graph_decomp.m
+++ b/matlab/graph_decomp.m
@@ -89,7 +89,7 @@ if isempty(initial_date)
     freq = 1;
 else
     freq = initial_date.freq;
-    initial_period = initial_date.time(1) + (initial_date.time(2)-1)/freq;
+    initial_period = double(initial_date);
     x = initial_period-1/freq:(1/freq):initial_period+(gend-1)/freq;
 end
 
diff --git a/matlab/graph_decomp_detail.m b/matlab/graph_decomp_detail.m
index aa12fe7e3a..b19a226b8b 100644
--- a/matlab/graph_decomp_detail.m
+++ b/matlab/graph_decomp_detail.m
@@ -89,7 +89,7 @@ if isempty(initial_date)
     freq = 1;
 else
     freq = initial_date.freq;
-    initial_period = initial_date.time(1) + (initial_date.time(2)-1)/freq;
+    initial_period = double(initial_date);
     x = initial_period-1/freq:(1/freq):initial_period+(gend-1)/freq;
 end
 
diff --git a/matlab/modules/reporting b/matlab/modules/reporting
index 57a4d66796..bf71d21523 160000
--- a/matlab/modules/reporting
+++ b/matlab/modules/reporting
@@ -1 +1 @@
-Subproject commit 57a4d6679636e0caa4f98e5a82fb4e33781643b4
+Subproject commit bf71d2152325fb5b743c5a61476da6944f73bfdf
diff --git a/matlab/plot_shock_decomposition.m b/matlab/plot_shock_decomposition.m
index 81df99c09b..11ca3b005a 100644
--- a/matlab/plot_shock_decomposition.m
+++ b/matlab/plot_shock_decomposition.m
@@ -286,7 +286,7 @@ if isequal(type,'aoa') && isstruct(q2a)
         % take all dates where realtime is saved
         qqq=options_.initial_date+options_.shock_decomp.save_realtime(:)-1;
         % take the first Q4 of saved realtime
-        t0=min(options_.shock_decomp.save_realtime(qqq.time(:,2)==4));
+        t0=min(options_.shock_decomp.save_realtime(subperiod(qqq)==4));
         if isempty(t0)
             error('the realtime decompositions are not stored in Q4! Please check your dates and settings.')
         end
@@ -421,12 +421,12 @@ switch type
         t0=1; % we assume the sample starts Q1 of 1st year
         initial_date = dates('1Y');
     else
-        initial_date0 = dates([int2str(initial_date.time(1)) 'Y']);
-        if initial_date.time(2)==1  % the first year is full
+        initial_date0 = dates([int2str(year(initial_date)) 'Y']);
+        if subperiod(initial_date)==1  % the first year is full
             t0=1;
             initial_date1=initial_date0;
         else
-            t0=(4-initial_date.time(2)+2); % 1st period of the 1st full year in sample
+            t0=(4-subperiod(initial_date)+2); % 1st period of the 1st full year in sample
             initial_date1=initial_date0+1;
         end
     end
@@ -492,16 +492,16 @@ switch type
         end
     else
         % this is for quarterly-annualized variables already defined in model, so we can just take Q4
-        t0=4-initial_date.time(2)+1;
+        t0=4-subperiod(initial_date)+1;
         initial_date = initial_date0;
         z=z(:,:,t0:4:end);
     end
 
     if ~isempty(options_.plot_shock_decomp.plot_init_date)
-        options_.plot_shock_decomp.plot_init_date = dates([int2str(options_.plot_shock_decomp.plot_init_date.time(1)) 'Y']);
+        options_.plot_shock_decomp.plot_init_date = dates([int2str(year(options_.plot_shock_decomp.plot_init_date)) 'Y']);
     end
     if ~isempty(options_.plot_shock_decomp.plot_end_date)
-        options_.plot_shock_decomp.plot_end_date = dates([int2str(options_.plot_shock_decomp.plot_end_date.time(1)) 'Y']);
+        options_.plot_shock_decomp.plot_end_date = dates([int2str(year(options_.plot_shock_decomp.plot_end_date)) 'Y']);
     end
 
 
-- 
GitLab