CC-3359: Now Playing -> Day view has a bug with supporting UTC time
-fixed
This commit is contained in:
parent
82812e15a5
commit
df22ab21a6
|
@ -67,40 +67,51 @@ class Application_Model_Nowplaying
|
||||||
return array("r", "", "", "", $p_showInstance->getName(), "", "", "", "", "", "");
|
return array("r", "", "", "", $p_showInstance->getName(), "", "", "", "", "", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetDataGridData($viewType, $dateString){
|
|
||||||
|
|
||||||
if ($viewType == "now"){
|
/*
|
||||||
$dateTime = new DateTime("now", new DateTimeZone("UTC"));
|
* The purpose of this function is to return an array of scheduled
|
||||||
$timeNow = $dateTime->format("Y-m-d H:i:s");
|
* items. There are two parameters. $p_viewType can be either "now"
|
||||||
|
* or "day". If "now", we show all scheduled items in the near future.
|
||||||
|
*
|
||||||
|
* If "day" we need to find what day was requested by the user, and return
|
||||||
|
* scheduled items for that day.
|
||||||
|
*
|
||||||
|
* $p_dateString is only used when $p_viewType is "day" it is in the format
|
||||||
|
* "2012-12-31". In this case it tells us which day to use.
|
||||||
|
*/
|
||||||
|
public static function GetDataGridData($p_viewType, $p_dateString){
|
||||||
|
|
||||||
$startCutoff = 60;
|
if ($p_viewType == "now"){
|
||||||
$endCutoff = 86400; //60*60*24 - seconds in a day
|
$start_dt = new DateTime("now", new DateTimeZone("UTC"));
|
||||||
|
$end_dt = clone $start_dt;
|
||||||
|
|
||||||
|
$start_dt->sub(new DateInterval("PT60S"));
|
||||||
|
$end_dt->add(new DateInterval("PT24H"));
|
||||||
} else {
|
} else {
|
||||||
$time = date("H:i:s");
|
Logging::log("HIII");
|
||||||
$utcDate = Application_Model_DateHelper::ConvertToUtcDateTimeString($dateString." ".$time);
|
|
||||||
|
|
||||||
$date = new Application_Model_DateHelper;
|
//convert to UTC
|
||||||
$date->setDate($utcDate);
|
$utc_dt = Application_Model_DateHelper::ConvertToUtcDateTime($p_dateString);
|
||||||
|
$start_dt = $utc_dt;
|
||||||
|
|
||||||
$timeNow = $date->getUtcTimestamp();
|
$end_dt = clone $utc_dt;
|
||||||
|
$end_dt->add(new DateInterval("PT24H"));
|
||||||
$startCutoff = $date->getNowDayStartDiff();
|
|
||||||
$endCutoff = $date->getNowDayEndDiff();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = array();
|
$starts = $start_dt->format("Y-m-d H:i:s");
|
||||||
|
$ends = $end_dt->format("Y-m-d H:i:s");
|
||||||
$showIds = Application_Model_ShowInstance::GetShowsInstancesIdsInRange($timeNow, $startCutoff, $endCutoff);
|
|
||||||
|
|
||||||
|
$showIds = Application_Model_ShowInstance::GetShowsInstancesIdsInRange($starts, $ends);
|
||||||
|
|
||||||
//get all the pieces to be played between the start cut off and the end cut off.
|
//get all the pieces to be played between the start cut off and the end cut off.
|
||||||
$scheduledItems = Application_Model_Schedule::getScheduleItemsInRange($timeNow, $startCutoff, $endCutoff);
|
$scheduledItems = Application_Model_Schedule::getScheduleItemsInRange($starts, $ends);
|
||||||
|
|
||||||
$orderedScheduledItems;
|
$orderedScheduledItems;
|
||||||
foreach ($scheduledItems as $scheduledItem){
|
foreach ($scheduledItems as $scheduledItem){
|
||||||
$orderedScheduledItems[$scheduledItem['instance_id']][] = $scheduledItem;
|
$orderedScheduledItems[$scheduledItem['instance_id']][] = $scheduledItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$data = array();
|
||||||
foreach ($showIds as $showId){
|
foreach ($showIds as $showId){
|
||||||
$instanceId = $showId['id'];
|
$instanceId = $showId['id'];
|
||||||
|
|
||||||
|
|
|
@ -354,7 +354,7 @@ class Application_Model_Schedule {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function getScheduleItemsInRange($timeNow, $start, $end)
|
public static function getScheduleItemsInRange($starts, $ends)
|
||||||
{
|
{
|
||||||
global $CC_DBC, $CC_CONFIG;
|
global $CC_DBC, $CC_CONFIG;
|
||||||
|
|
||||||
|
@ -380,9 +380,9 @@ class Application_Model_Schedule {
|
||||||
." ON st.file_id = ft.id"
|
." ON st.file_id = ft.id"
|
||||||
." LEFT JOIN ".$CC_CONFIG["showTable"]." s"
|
." LEFT JOIN ".$CC_CONFIG["showTable"]." s"
|
||||||
." ON si.show_id = s.id"
|
." ON si.show_id = s.id"
|
||||||
." WHERE ((si.starts < TIMESTAMP '$timeNow' - INTERVAL '$start seconds' AND si.ends > TIMESTAMP '$timeNow' - INTERVAL '$start seconds')"
|
." WHERE ((si.starts < TIMESTAMP '$starts' AND si.ends > TIMESTAMP '$starts')"
|
||||||
." OR (si.starts > TIMESTAMP '$timeNow' - INTERVAL '$start seconds' AND si.ends < TIMESTAMP '$timeNow' + INTERVAL '$end seconds')"
|
." OR (si.starts > TIMESTAMP '$starts' AND si.ends < TIMESTAMP '$ends')"
|
||||||
." OR (si.starts < TIMESTAMP '$timeNow' + INTERVAL '$end seconds' AND si.ends > TIMESTAMP '$timeNow' + INTERVAL '$end seconds'))"
|
." OR (si.starts < TIMESTAMP '$ends' AND si.ends > TIMESTAMP '$ends'))"
|
||||||
." AND (st.starts < si.ends)"
|
." AND (st.starts < si.ends)"
|
||||||
." ORDER BY si.id, si.starts, st.starts";
|
." ORDER BY si.id, si.starts, st.starts";
|
||||||
|
|
||||||
|
|
|
@ -700,21 +700,23 @@ class Application_Model_ShowInstance {
|
||||||
return $items;
|
return $items;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetShowsInstancesIdsInRange($p_timeNow, $p_start, $p_end)
|
public static function GetShowsInstancesIdsInRange($p_start, $p_end)
|
||||||
{
|
{
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
$sql = "SELECT id FROM cc_show_instances AS si "
|
$sql = "SELECT id FROM cc_show_instances AS si "
|
||||||
."WHERE modified_instance != TRUE AND ("
|
."WHERE modified_instance != TRUE AND ("
|
||||||
."(si.starts < TIMESTAMP '$p_timeNow' - INTERVAL '$p_start seconds' "
|
."(si.starts < TIMESTAMP '$p_start'"
|
||||||
."AND si.ends > TIMESTAMP '$p_timeNow' - INTERVAL '$p_start seconds') "
|
."AND si.ends > TIMESTAMP '$p_start') "
|
||||||
."OR (si.starts > TIMESTAMP '$p_timeNow' - INTERVAL '$p_start seconds' "
|
."OR (si.starts > TIMESTAMP '$p_start' "
|
||||||
."AND si.ends < TIMESTAMP '$p_timeNow' + INTERVAL '$p_end seconds') "
|
."AND si.ends < TIMESTAMP '$p_end') "
|
||||||
."OR (si.starts < TIMESTAMP '$p_timeNow' + INTERVAL '$p_end seconds' "
|
."OR (si.starts < TIMESTAMP '$p_end' "
|
||||||
."AND si.ends > TIMESTAMP '$p_timeNow' + INTERVAL '$p_end seconds') "
|
."AND si.ends > TIMESTAMP '$p_end') "
|
||||||
.") "
|
.") "
|
||||||
." ORDER BY si.starts";
|
." ORDER BY si.starts";
|
||||||
|
|
||||||
|
Logging::debug($sql);
|
||||||
|
|
||||||
$rows = $CC_DBC->GetAll($sql);
|
$rows = $CC_DBC->GetAll($sql);
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue