It's also possible to be in month 1, while in ISO week 52.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Mon, 7 Jun 2010 13:48:05 +0000 (09:48 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Mon, 7 Jun 2010 13:49:23 +0000 (09:49 -0400)
Fixes Bug: 8799

framework/Date/lib/Horde/Date/Recurrence.php

index bd76fd9..1d475a9 100644 (file)
@@ -386,13 +386,17 @@ class Horde_Date_Recurrence
             $start_week->sec  = $this->start->sec;
 
             // Make sure we are not at the ISO-8601 first week of year while
-            // still in month 12...and adjust the year ahead if we are.
+            // still in month 12...OR in the ISO-8601 last week of year while
+            // in month 1 and adjust the year accordingly.
             $week = $after->format('W');
             if ($week == 1 && $after->month == 12) {
                 $theYear = $after->year + 1;
+            } elseif ($week == 52 && $after->month == 1) {
+                $theYear = $after->year - 1;
             } else {
                 $theYear = $after->year;
             }
+
             $after_week = Horde_Date_Utils::firstDayOfWeek($week, $theYear);
             $after_week_end = clone $after_week;
             $after_week_end->mday += 7;