diff --git a/src/mtime_timedelta.c b/src/mtime_timedelta.c
index d1f186305714db03c7c3e0e92fad8291016a3bde..a45d80d593b4c7505dc689d872c27d68f881748a 100644
--- a/src/mtime_timedelta.c
+++ b/src/mtime_timedelta.c
@@ -895,9 +895,9 @@ julianDeltaToTimeDelta(struct _juliandelta* jd, struct _datetime* base_dt, struc
           /* No of days in the final year */
           int64_t delta_final_year;
           int64_t days = (-1)*jd->day;
-          /* Set counter to base year and then jump forward to get to the final year.
-           For each loop forward, increment year by 1.
-           */
+          /* Set counter to base year and then iterate backward to get to the final year.
+             For each loop forward, increment year by 1.
+          */
           int64_t j = base_dt->date.year;
           /* Initialize to 0. */
           td_return->year = 0;
@@ -921,16 +921,16 @@ julianDeltaToTimeDelta(struct _juliandelta* jd, struct _datetime* base_dt, struc
               /* The crucial point is month of february. */
               delta_final_year = days;
               if (
-                        ( (testYearIsLeapYear(j + 1)) && (base_dt->date.month >= 3) )
-                        ||
-                        ( (testYearIsLeapYear(j)) && (base_dt->date.month < 3) )
-                 )
+                  ( (testYearIsLeapYear(j)) && (base_dt->date.month >= 3) )
+                  ||
+                  ( (testYearIsLeapYear(j-1)) && (base_dt->date.month < 3) )
+                  )
                 {
-                  /* If next year is leap year and base month is >= 3 
-                   OR 
-                   this year is a leap year and month is < 3
-                   => delta of 1 year corresponds to 366 day julian delta.  
-                   */
+                  /* If year is leap year and base month is >= 3
+                     OR
+                     next year is a leap year and month is < 3
+                     => delta of 1 year corresponds to 366 day julian delta.
+                  */
                   days = days - NO_OF_DAYS_IN_A_LEAP_YEAR;
                 }
               else
@@ -939,27 +939,30 @@ julianDeltaToTimeDelta(struct _juliandelta* jd, struct _datetime* base_dt, struc
                   days = days - NO_OF_DAYS_IN_A_YEAR_FOR_CAL_TYPE365;
                 }
               td_return->year++;
-              j++;
-            }while (days >= 0);
+              j--;
+            } while (days >= 0);
+
           /* The loop ran one time too much. */
+
           if (days < 0)
             {
               td_return->year--;
-              j--;
+              j++;
             }
 
           /* In final year, the crucial point is the month of february. */
+
           if (
-                ((testYearIsLeapYear(j + 1)) && (base_dt->date.month >= 3))
-                ||
-                ((testYearIsLeapYear(j)) && (base_dt->date.month < 3))
-             )
+              ((testYearIsLeapYear(j)) && (base_dt->date.month >= 3))
+              ||
+              ((testYearIsLeapYear(j-1)) && (base_dt->date.month < 3))
+              )
             {
-              /* If final year's next year is a leap year and base month is >= 3 
-               OR 
-               final year is a leap year and month is < 3
-               => An addition of leap-year specific delta for each month.
-               */
+              /* If final year is a leap year and base month is >= 3
+                 OR
+                 year preceding final year is a leap year and month is < 3
+                 => An addition of leap-year specific delta for each month.
+              */
               msdinm = monthSpecificDeltaInMonthsLeapyear;
               ndiny = NO_OF_DAYS_IN_A_LEAP_YEAR;
             }
@@ -1020,15 +1023,15 @@ julianDeltaToTimeDelta(struct _juliandelta* jd, struct _datetime* base_dt, struc
               /* The crucial point is month of february. */
               delta_final_year = days;
               if (
-                        ((testYearIsLeapYear(j - 1)) && (base_dt->date.month < 3))
-                        ||
-                        ((testYearIsLeapYear(j)) && (base_dt->date.month >= 3))
-                 )
+                  ((testYearIsLeapYear(j+1)) && (base_dt->date.month >= 3))
+                  ||
+                  ((testYearIsLeapYear(j)) && (base_dt->date.month < 3))
+                  )
                 {
-                  /* If previous year is leap year and base month is < 3 
-                   OR 
-                   this year is a leap year and month is >= 3
-                   => delta of 1 year corresponds to 366 day julian delta.  
+                  /* If next year is leap year and base month is < 3
+                     OR
+                     this year is a leap year and month is < 3
+                     => delta of 1 year corresponds to 366 day julian delta.
                   */
                   days = days - NO_OF_DAYS_IN_A_LEAP_YEAR;
                 }
@@ -1039,26 +1042,27 @@ julianDeltaToTimeDelta(struct _juliandelta* jd, struct _datetime* base_dt, struc
                 }
 
               td_return->year++;
-              j--;
-            }while (days >= 0);
+              j++;
+            } while (days >= 0);
+
           /* The loop ran one time too much. */
           if (days < 0)
             {
               td_return->year--;
-              j++;
+              j--;
             }
 
           /* In final year, the crucial point is the month of february. */
           if (
-                ((testYearIsLeapYear(j - 1)) && (base_dt->date.month < 3))
-                ||
-                ((testYearIsLeapYear(j)) && (base_dt->date.month >= 3))
-             )
+              ((testYearIsLeapYear(j+1)) && (base_dt->date.month >= 3))
+              ||
+              ((testYearIsLeapYear(j)) && (base_dt->date.month < 3))
+              )
             {
-              /* If final year is a leap year and base month is >= 3 
-               OR 
-               final year's previous year is a leap year and month is < 3
-               => An addition of leap-year specific delta for each month.
+              /* If final year is a leap year and base month is >= 3
+                 OR
+                 final year's previous year is a leap year and month is < 3
+                 => An addition of leap-year specific delta for each month.
               */
               msdinm = monthSpecificDeltaInMonthsLeapyear;
               ndiny = NO_OF_DAYS_IN_A_LEAP_YEAR;