From 7342ea4d4b6ad95a0ab278ee6ce15c1d06fc41ff Mon Sep 17 00:00:00 2001 From: james Date: Tue, 3 Jul 2012 13:17:48 -0400 Subject: [PATCH] CC-4053: Widget not showing correct day on Sunday - fixed weekly widget - also fixed today's show widget --- airtime_mvc/application/common/DateHelper.php | 3 +- .../application/controllers/ApiController.php | 29 ++++++++++++------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/airtime_mvc/application/common/DateHelper.php b/airtime_mvc/application/common/DateHelper.php index 84c5feb0c..747b85868 100644 --- a/airtime_mvc/application/common/DateHelper.php +++ b/airtime_mvc/application/common/DateHelper.php @@ -53,7 +53,8 @@ class Application_Common_DateHelper */ function getWeekStartDate() { - $startDate = date('w') == 0 ? date('Y-m-d') : date('Y-m-d', strtotime('monday this week')); + // our week starts on monday, but php week starts on sunday. + $startDate = date('w') == 0 ? date('Y-m-d', strtotime('monday last week')) : date('Y-m-d', strtotime('monday this week')); $startDateTime = new DateTime($startDate); return $startDateTime->format('Y-m-d H:i:s'); } diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index a29054ed9..ad7ef5378 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -274,20 +274,27 @@ class ApiController extends Zend_Controller_Action if($type == "endofday") { // make GetNextShows use end of day $utcTimeEnd = Application_Common_DateHelper::GetDayEndTimestampInUtc(); + $result = array("env"=>APPLICATION_ENV, + "schedulerTime"=>gmdate("Y-m-d H:i:s"), + "nextShow"=>Application_Model_Show::GetNextShows($utcTimeNow, 5, $utcTimeEnd)); + + Application_Model_Show::ConvertToLocalTimeZone($result["nextShow"], array("starts", "ends", "start_timestamp", "end_timestamp")); + }else{ + + $limit = $request->getParam('limit'); + if($limit == "" || !is_numeric($limit)) { + $limit = "5"; + } + + $result = Application_Model_Schedule::GetPlayOrderRange(); + + //Convert from UTC to localtime for user. + Application_Model_Show::ConvertToLocalTimeZone($result["currentShow"], array("starts", "ends", "start_timestamp", "end_timestamp")); + Application_Model_Show::ConvertToLocalTimeZone($result["nextShow"], array("starts", "ends", "start_timestamp", "end_timestamp")); } - - $limit = $request->getParam('limit'); - if($limit == "" || !is_numeric($limit)) { - $limit = "5"; - } - - $result = Application_Model_Schedule::GetPlayOrderRange(); + $result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION; //used by caller to determine if the airtime they are running or widgets in use is out of date. - //Convert from UTC to localtime for user. - Application_Model_Show::ConvertToLocalTimeZone($result["currentShow"], array("starts", "ends", "start_timestamp", "end_timestamp")); - Application_Model_Show::ConvertToLocalTimeZone($result["nextShow"], array("starts", "ends", "start_timestamp", "end_timestamp")); - //echo json_encode($result); header("Content-type: text/javascript"); echo $_GET['callback'].'('.json_encode($result).')';