From 8b528b8f53ac22b20df81b690e1ae6b0ff07880c Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Sun, 30 Aug 2009 12:01:58 +0200 Subject: [PATCH] MFB: Fix exporting certain weekday recurrence rules to iCalendar (lst_hoe02@kwsoft.de, Bug #8510). --- framework/Date/lib/Horde/Date/Recurrence.php | 39 ++++++++++------------------ 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/framework/Date/lib/Horde/Date/Recurrence.php b/framework/Date/lib/Horde/Date/Recurrence.php index 5d42289ac..e9191c1dc 100644 --- a/framework/Date/lib/Horde/Date/Recurrence.php +++ b/framework/Date/lib/Horde/Date/Recurrence.php @@ -939,20 +939,14 @@ class Horde_Date_Recurrence break; case self::RECUR_MONTHLY_WEEKDAY: - $next_week = new Horde_Date($this->start); - $next_week->mday += 7; - - if ($this->start->month != $next_week->month) { - $p = 5; - } else { - $p = (int)($this->start->mday / 7); - if (($this->start->mday % 7) > 0) { - $p++; - } + $nth_weekday = (int)($this->start->mday / 7); + if (($this->start->mday % 7) > 0) { + $nth_weekday++; } $vcaldays = array('SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA'); - $rrule = 'MP' . $this->recurInterval . ' ' . $p . '+ ' . $vcaldays[$this->start->dayOfWeek()]; + $rrule = 'MP' . $this->recurInterval . ' ' . $nth_weekday . '+ ' . $vcaldays[$this->start->dayOfWeek()]; + break; case self::RECUR_YEARLY_DATE: @@ -1115,19 +1109,13 @@ class Horde_Date_Recurrence break; case self::RECUR_MONTHLY_WEEKDAY: - $next_week = new Horde_Date($this->start); - $next_week->mday += 7; - if ($this->start->month != $next_week->month) { - $p = 5; - } else { - $p = (int)($this->start->mday / 7); - if (($this->start->mday % 7) > 0) { - $p++; - } + $nth_weekday = (int)($this->start->mday / 7); + if (($this->start->mday % 7) > 0) { + $nth_weekday++; } $vcaldays = array('SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA'); $rrule = 'FREQ=MONTHLY;INTERVAL=' . $this->recurInterval - . ';BYDAY=' . $p . $vcaldays[$this->start->dayOfWeek()]; + . ';BYDAY=' . $nth_weekday . $vcaldays[$this->start->dayOfWeek()]; break; case self::RECUR_YEARLY_DATE: @@ -1140,13 +1128,14 @@ class Horde_Date_Recurrence break; case self::RECUR_YEARLY_WEEKDAY: + $nth_weekday = (int)($this->start->mday / 7); + if (($this->start->mday % 7) > 0) { + $nth_weekday++; + } $vcaldays = array('SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA'); - $weekday = new Horde_Date(array('month' => $this->start->month, - 'mday' => 1, - 'year' => $this->start->year)); $rrule = 'FREQ=YEARLY;INTERVAL=' . $this->recurInterval . ';BYDAY=' - . ($this->start->weekOfYear() - $weekday->weekOfYear() + 1) + . $nth_weekday . $vcaldays[$this->start->dayOfWeek()] . ';BYMONTH=' . $this->start->month; break; -- 2.11.0