CC-3037: Nowplaying bar not showing current show
-fixed
This commit is contained in:
parent
fe5191eac1
commit
a0217f715f
6 changed files with 72 additions and 40 deletions
|
@ -245,11 +245,22 @@ class Application_Model_DateHelper
|
|||
return $dateTime;
|
||||
}
|
||||
|
||||
public static function ConvertToLocalDateTimeString($p_dateString, $format="Y-m-d H:i:s"){
|
||||
$dateTime = new DateTime($p_dateString, new DateTimeZone("UTC"));
|
||||
$dateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||
|
||||
return $dateTime->format($format);
|
||||
/* Convenience method to return a date formatted into a String rather than a
|
||||
* DateTime object. Note that if an empty string is provided for $p_dateString
|
||||
* then the current time is provided.
|
||||
*
|
||||
* @param $p_dateString
|
||||
* Date string in UTC timezone.
|
||||
* @param $p_format
|
||||
* Format which the string should be returned in.
|
||||
*
|
||||
* @return string
|
||||
* Date String in localtime
|
||||
* */
|
||||
public static function ConvertToLocalDateTimeString($p_dateString, $p_format="Y-m-d H:i:s"){
|
||||
if (is_null($p_dateString) || strlen($p_dateString) == 0)
|
||||
return $p_dateString;
|
||||
return self::ConvertToLocalDateTime($p_dateString)->format($p_format);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -101,7 +101,9 @@ class Application_Model_Nowplaying
|
|||
$data[] = self::CreateGapRow($gapTime);
|
||||
}
|
||||
|
||||
return array("currentShow"=>Application_Model_Show::GetCurrentShow($timeNow), "rows"=>$data);
|
||||
$rows = Application_Model_Show::GetCurrentShow($timeNow);
|
||||
Application_Model_Show::ConvertToLocalTimeZone($rows, array("starts", "ends", "start_timestamp", "end_timestamp"));
|
||||
return array("currentShow"=>$rows, "rows"=>$data);
|
||||
}
|
||||
|
||||
public static function ShouldShowPopUp(){
|
||||
|
|
|
@ -145,15 +145,18 @@ class Application_Model_Schedule {
|
|||
|
||||
$date = new Application_Model_DateHelper;
|
||||
$timeNow = $date->getTimestamp();
|
||||
return array("env"=>APPLICATION_ENV,
|
||||
$utcTimeNow = $date->getUtcTimestamp();
|
||||
$range = array("env"=>APPLICATION_ENV,
|
||||
"schedulerTime"=>$timeNow,
|
||||
"previous"=>Application_Model_Dashboard::GetPreviousItem($timeNow),
|
||||
"current"=>Application_Model_Dashboard::GetCurrentItem($timeNow),
|
||||
"next"=>Application_Model_Dashboard::GetNextItem($timeNow),
|
||||
"currentShow"=>Application_Model_Show::GetCurrentShow($timeNow),
|
||||
"nextShow"=>Application_Model_Show::GetNextShows($timeNow, 1),
|
||||
"previous"=>Application_Model_Dashboard::GetPreviousItem($utcTimeNow),
|
||||
"current"=>Application_Model_Dashboard::GetCurrentItem($utcTimeNow),
|
||||
"next"=>Application_Model_Dashboard::GetNextItem($utcTimeNow),
|
||||
"currentShow"=>Application_Model_Show::GetCurrentShow($utcTimeNow),
|
||||
"nextShow"=>Application_Model_Show::GetNextShows($utcTimeNow, 1),
|
||||
"timezone"=> date("T"),
|
||||
"timezoneOffset"=> date("Z"));
|
||||
|
||||
return $range;
|
||||
}
|
||||
|
||||
public static function GetLastScheduleItem($p_timeNow){
|
||||
|
|
|
@ -1373,20 +1373,15 @@ class Application_Model_Show {
|
|||
public static function GetCurrentShow($timeNow)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
||||
// Need this in the query below, so that we are NOT comparing UTC
|
||||
// timestamps si.starts/si.ends with local timestamps $timeNow
|
||||
$timezoneInterval = Application_Model_Show::GetTimezoneIntervalString(true);
|
||||
|
||||
$sql = "SELECT si.starts as start_timestamp, si.ends as end_timestamp, s.name, s.id, si.id as instance_id, si.record, s.url"
|
||||
." FROM $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s"
|
||||
." WHERE si.show_id = s.id"
|
||||
." AND si.starts <= TIMESTAMP '$timeNow' + $timezoneInterval"
|
||||
." AND si.ends > TIMESTAMP '$timeNow' + $timezoneInterval";
|
||||
." AND si.starts <= TIMESTAMP '$timeNow'"
|
||||
." AND si.ends > TIMESTAMP '$timeNow'";
|
||||
|
||||
// Convert back to local timezone
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
Application_Model_Show::ConvertToLocalTimeZone($rows, array("starts", "ends", "start_timestamp", "end_timestamp"));
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
@ -1404,30 +1399,24 @@ class Application_Model_Show {
|
|||
public static function GetNextShows($timeNow, $limit, $timeEnd = "")
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
||||
// Need this in the query below, so that we are NOT comparing UTC
|
||||
// timestamps si.starts with local timestamps $timeNow
|
||||
$timezoneInterval = Application_Model_Show::GetTimezoneIntervalString(true);
|
||||
|
||||
|
||||
// defaults to retrieving shows from next 2 days if no end time has
|
||||
// been specified
|
||||
if($timeEnd == "") {
|
||||
$timeEnd = "'$timeNow' + INTERVAL '2 days' + $timezoneInterval";
|
||||
$timeEnd = "'$timeNow' + INTERVAL '2 days'";
|
||||
} else {
|
||||
$timeEnd = "'$timeEnd' + $timezoneInterval";
|
||||
$timeEnd = "'$timeEnd'";
|
||||
}
|
||||
|
||||
$sql = "SELECT *, si.starts as start_timestamp, si.ends as end_timestamp FROM "
|
||||
." $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s"
|
||||
." WHERE si.show_id = s.id"
|
||||
." AND si.starts >= TIMESTAMP '$timeNow' + $timezoneInterval"
|
||||
." AND si.starts >= TIMESTAMP '$timeNow'"
|
||||
." AND si.starts < TIMESTAMP $timeEnd"
|
||||
." ORDER BY si.starts"
|
||||
." LIMIT $limit";
|
||||
|
||||
// Convert timestamps to local timezone
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
Application_Model_Show::ConvertToLocalTimeZone($rows, array("starts", "ends", "start_timestamp", "end_timestamp"));
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
@ -1447,12 +1436,7 @@ class Application_Model_Show {
|
|||
//Result: 5
|
||||
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
||||
// Need this in the query below, so that we are NOT extracting DOW and WEEK
|
||||
// information from UTC timestamps si.starts, and comparing with a local
|
||||
// timezone based variable $day and localtimestamp
|
||||
$timezoneInterval = Application_Model_Show::GetTimezoneIntervalString();
|
||||
|
||||
|
||||
$sql = "SELECT"
|
||||
." si.starts as show_starts,"
|
||||
." si.ends as show_ends,"
|
||||
|
@ -1461,13 +1445,12 @@ class Application_Model_Show {
|
|||
." FROM $CC_CONFIG[showInstances] si"
|
||||
." LEFT JOIN $CC_CONFIG[showTable] s"
|
||||
." ON si.show_id = s.id"
|
||||
." WHERE EXTRACT(DOW FROM si.starts + $timezoneInterval) = $day"
|
||||
." AND EXTRACT(WEEK FROM si.starts + $timezoneInterval) = EXTRACT(WEEK FROM localtimestamp)"
|
||||
." WHERE EXTRACT(DOW FROM si.starts) = $day"
|
||||
." AND EXTRACT(WEEK FROM si.starts) = EXTRACT(WEEK FROM localtimestamp)"
|
||||
." ORDER BY si.starts";
|
||||
|
||||
// Convert result timestamps to local timezone
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
Application_Model_Show::ConvertToLocalTimeZone($rows, array("show_starts", "show_ends"));
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
@ -1501,6 +1484,7 @@ class Application_Model_Show {
|
|||
*
|
||||
* @param type $fromLocalToUtc true if we're converting from local to UTC
|
||||
*/
|
||||
/*
|
||||
public static function GetTimeZoneIntervalString($fromLocalToUtc = false) {
|
||||
$date = new Application_Model_DateHelper;
|
||||
$timezoneHour = $date->getLocalOffsetHour();
|
||||
|
@ -1514,6 +1498,7 @@ class Application_Model_Show {
|
|||
|
||||
return "INTERVAL '$timezoneHour hours $timezoneMin minutes'";
|
||||
}
|
||||
* */
|
||||
|
||||
public static function GetMaxLengths() {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue