From 548a6ce16a4e6c87f4b508a019ceceeee42e2fe9 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 12 Jun 2012 17:49:34 -0400 Subject: [PATCH 1/3] CC-3957: Make Schedule Widgets show future Sunday instead of past Sunday - bug fix --- airtime_mvc/application/common/DateHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airtime_mvc/application/common/DateHelper.php b/airtime_mvc/application/common/DateHelper.php index 3f7e29006..84c5feb0c 100644 --- a/airtime_mvc/application/common/DateHelper.php +++ b/airtime_mvc/application/common/DateHelper.php @@ -53,7 +53,7 @@ class Application_Common_DateHelper */ function getWeekStartDate() { - $startDate = date('w') == 0 ? date('Y-m-d') : date('Y-m-d', strtotime('monday')); + $startDate = date('w') == 0 ? date('Y-m-d') : date('Y-m-d', strtotime('monday this week')); $startDateTime = new DateTime($startDate); return $startDateTime->format('Y-m-d H:i:s'); } From b858c34526ab439c528c71b09766452d593847b8 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 12 Jun 2012 18:51:22 -0400 Subject: [PATCH 2/3] CC-3956: PHP script can enter inifinite loop -fixed --- airtime_mvc/application/models/Show.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index 6cfe7a335..26ef64ab1 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -1310,7 +1310,7 @@ class Application_Model_Show { if ($ccShowInstance->getDbModifiedInstance()){ //show instance on this date has been deleted. - $utcStartDateTime = self::advanceRepeatingDate($p_interval, $start, $timezone); + list($start, $utcStartDateTime) = self::advanceRepeatingDate($p_interval, $start, $timezone); continue; } @@ -1343,7 +1343,7 @@ class Application_Model_Show { $showInstance->deleteRebroadcasts(); self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $start, $duration, $timezone); - $utcStartDateTime = self::advanceRepeatingDate($p_interval, $start, $timezone); + list($start, $utcStartDateTime) = self::advanceRepeatingDate($p_interval, $start, $timezone); } @@ -1383,7 +1383,7 @@ class Application_Model_Show { $dt->setTimezone(new DateTimeZone('UTC')); $utcStartDateTime = $dt; } - return $utcStartDateTime; + return array($start, $utcStartDateTime); } /* From 02b6d049527fff004650b08a5cb3ab0f77021fce Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 12 Jun 2012 20:18:06 -0400 Subject: [PATCH 3/3] CC-3956: PHP script can enter inifinite loop -small cleanup --- airtime_mvc/application/models/Show.php | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index 26ef64ab1..298aafb37 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -1359,30 +1359,28 @@ class Application_Model_Show { * over the years 2011->2012, etc.). Then let's append the actual day, and use the php * checkdate() function, to see if it is valid. If not, then we'll just skip this month. */ - /* pass in only the year and month (not the day) */ - $dt = new DateTime($startDt->format("Y-m"), new DateTimeZone($timezone)); - + /* pass in only the year and month (not the day) */ $dt = new DateTime($startDt->format("Y-m"), new DateTimeZone($timezone)); + /* Keep adding 1 month, until we find the next month that contains the day * we are looking for (31st day for example) */ do { $dt->add(new DateInterval($p_interval)); } while(!checkdate($dt->format("m"), $startDt->format("d"), $dt->format("Y"))); + $dt->setDate($dt->format("Y"), $dt->format("m"), $startDt->format("d")); - - $start = $dt->format("Y-m-d H:i:s"); - - $dt->setTimezone(new DateTimeZone('UTC')); - $utcStartDateTime = $dt; + } else { $dt = new DateTime($start, new DateTimeZone($timezone)); $dt->add(new DateInterval($p_interval)); - $start = $dt->format("Y-m-d H:i:s"); - - $dt->setTimezone(new DateTimeZone('UTC')); - $utcStartDateTime = $dt; } + + $start = $dt->format("Y-m-d H:i:s"); + + $dt->setTimezone(new DateTimeZone('UTC')); + $utcStartDateTime = $dt; + return array($start, $utcStartDateTime); }