From 6c71b170244c677cb19e1688615e327f0323618a Mon Sep 17 00:00:00 2001 From: drigato Date: Wed, 4 Dec 2013 10:05:32 -0500 Subject: [PATCH] CC-5595: Improper day of week comparison Need to convert show instance start time to the show's local timezone before getting the repeat day of week --- airtime_mvc/application/services/ShowService.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/services/ShowService.php b/airtime_mvc/application/services/ShowService.php index 32b018f6a..b8a89e18f 100644 --- a/airtime_mvc/application/services/ShowService.php +++ b/airtime_mvc/application/services/ShowService.php @@ -743,14 +743,23 @@ SQL; */ else if (count($ccShowInstances) >= 1) { $lastShowDays = array(); + + //get the show's timezone + $ccShow = CcShowQuery::create()->findPk($showId); + if ($ccShow->isRepeating()) { + $showTimezone = $ccShow->getFirstRepeatingCcShowDay()->getDbTimezone(); + } else { + $showTimezone = $ccShow->getFirstCcShowDay()->getDbTimezone(); + } + /* Creates an array where the key is the day of the week (monday, * tuesday, etc.) and the value is the last show date for each * day of the week. We will use this array to update the last_show * for each cc_show_days entry of a cc_show */ foreach ($ccShowInstances as $instance) { - $instanceStartDT = new DateTime($instance->getDbStarts(), - new DateTimeZone("UTC")); + $instanceStartDT = $instance->getDbStarts(null); + $instanceStartDT->setTimezone(new DateTimeZone($showTimezone)); $lastShowDays[$instanceStartDT->format("w")] = $instanceStartDT; }