CC-2965: Frontend widget displays shows in UTC time
Not only were frontend widgets showing UTC time, the SQL query was also comparing UTC timestamp with local timestamps, causing widgets to display shows in the wrong day, etc. Another problem was that "On air today" widget was simply calling GetNextShows which returns shows within next 48 hours. Fixed by: 1. Under models/Show.php: In the GetCurrentShow/GetNextShows/GetShowsByDayOfWeek functions, added code to convert UTC timestamp to local timestamp or vice versa, depending on which one is more suitable, in SQL queries, thus removing inconsistency in timezones. Also, before returning query result, added code to convert result to local timezone. In GetNextShows, added an optional parameter endTime to limit the interval of shows to get. This is useful for the "On air today" widget. 2. Under models/DateHelper.php: Added a few timezone functions to help converting timezones easier in Show.php. 3. Under controller/ApiController.php: Added todayInfoAction which is to be used by "On Air Today" widget.
This commit is contained in:
parent
9506161b70
commit
6ffecf80c8
4 changed files with 201 additions and 40 deletions
|
@ -199,6 +199,30 @@ class ApiController extends Zend_Controller_Action
|
|||
}
|
||||
}
|
||||
|
||||
public function todayInfoAction()
|
||||
{
|
||||
if (Application_Model_Preference::GetAllow3rdPartyApi()){
|
||||
// disable the view and the layout
|
||||
$this->view->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
$date = new Application_Model_DateHelper;
|
||||
$timeNow = $date->getTimestamp();
|
||||
$timeEnd = $date->getDayEndTimestamp();
|
||||
|
||||
$result = array("env"=>APPLICATION_ENV,
|
||||
"schedulerTime"=>gmdate("Y-m-d H:i:s"),
|
||||
"nextShow"=>Application_Model_Show::GetNextShows($timeNow, 5, $timeEnd));
|
||||
|
||||
header("Content-type: text/javascript");
|
||||
echo $_GET['callback'].'('.json_encode($result).')';
|
||||
} else {
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
print 'You are not allowed to access this resource. ';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function weekInfoAction()
|
||||
{
|
||||
if (Application_Model_Preference::GetAllow3rdPartyApi()){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue