From ccb3da3192defdc3ec09a6b6c044156615af327f Mon Sep 17 00:00:00 2001 From: denise Date: Wed, 5 Jun 2013 16:16:57 -0400 Subject: [PATCH] CC-5209: Calendar -> Repeat by 5th day of the week problem --- airtime_mvc/application/services/ShowService.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/services/ShowService.php b/airtime_mvc/application/services/ShowService.php index 5a4fc130f..735b415da 100644 --- a/airtime_mvc/application/services/ShowService.php +++ b/airtime_mvc/application/services/ShowService.php @@ -872,7 +872,9 @@ SQL; Application_Common_DateHelper::ConvertToUtcDateTime($last_show, $timezone) : null; $utcStartDateTime = new DateTime("now"); + $previousDate = clone $start; foreach ($datePeriod as $date) { + list($utcStartDateTime, $utcEndDateTime) = $this->createUTCStartEndDateTime( $date, $duration); /* @@ -926,6 +928,7 @@ SQL; $this->createRebroadcastInstances($showDay, $date, $ccShowInstance->getDbId()); } } + $previousDate = clone $date; } /* Set UTC to local time before setting the next repeat date. If we don't @@ -933,6 +936,16 @@ SQL; */ $utcStartDateTime->setTimezone(new DateTimeZone(Application_Model_Preference::GetTimezone())); $nextDate = $utcStartDateTime->add($repeatInterval); + if ($repeatType == REPEAT_MONTHLY_WEEKLY) { + $previousMonth = ltrim($previousDate->format("m"), "0"); + $nextMonth = ltrim($nextDate->format("m"), "0"); + if ($nextMonth != $previousMonth+1) { + $repeatInterval = DateInterval::createFromDateString( + "fourth ".$dayOfWeek." of next month"); + } + } + Logging::info("PREVIOUS --- ".$previousDate->format("Y-m-d H:i:s")); + Logging::info("NEXT ------- ".$nextDate->format("Y-m-d H:i:s")); $this->setNextRepeatingShowDate($nextDate->format("Y-m-d"), $day, $show_id); } @@ -1018,7 +1031,6 @@ SQL; private function getMonthlyWeeklyRepeatInterval($showStart) { $start = clone $showStart; - $dayOfMonth = $start->format("j"); $dayOfWeek = $start->format("l"); $yearAndMonth = $start->format("Y-m"); @@ -1047,7 +1059,7 @@ SQL; $weekNumberOfMonth = "fourth"; break; case 5: - $weekNumberOfMonth = "last"; + $weekNumberOfMonth = "fifth"; break; }