From b7ff26c8aa788f791f8d4d093dc10fc81e119a23 Mon Sep 17 00:00:00 2001
From: Ferhat Mihoubi <ferhat.mihoubi@univ-evry.fr>
Date: Thu, 13 Jun 2013 11:02:38 +0200
Subject: [PATCH] Correct the way to handle the frequencies when a number of
 periods is added to a dynDate

---
 matlab/@dynDate/plus.m | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/matlab/@dynDate/plus.m b/matlab/@dynDate/plus.m
index e110596bd2..3101268817 100644
--- a/matlab/@dynDate/plus.m
+++ b/matlab/@dynDate/plus.m
@@ -67,10 +67,10 @@ switch a.freq
     c.time(1) = a.time(1) + b - 1;
   case {4,12,52}
     c = a;
-    n1 = b;
-    n2 = floor(n1/a.freq);
-    n3 = mod(n1,a.freq);
-    c.time(2) = c.time(2)+n3-1;
+    n1 = b + a.time(2);
+    n2 = floor((n1 - 1)/a.freq);
+    n3 = mod(n1 - 1,a.freq) + 1;
+    c.time(2) = n3;
     c.time(1) = c.time(1)+n2;
   otherwise
     error('dynDate::plus: Unknown frequency!')
-- 
GitLab