cc-2683: not using utc time

-context menu showing options display correctly
-edit show fills in correctly
-Now Playing view shows up correctly
This commit is contained in:
martin 2011-08-15 16:40:24 -04:00
parent 03f8163764
commit 41fd5f2543
7 changed files with 109 additions and 57 deletions

View file

@ -3,21 +3,31 @@
class Application_Model_Nowplaying
{
public static function CreateHeaderRow($p_showName, $p_showStart, $p_showEnd){
private static function CreateHeaderRow($p_showName, $p_showStart, $p_showEnd){
return array("h", "", $p_showStart, $p_showEnd, $p_showName, "", "", "", "", "", "");
}
public static function CreateDatatableRows($p_dbRows){
private static function CreateDatatableRows($p_dbRows){
$dataTablesRows = array();
$date = new DateHelper;
$timeNow = $date->getTimestamp();
$epochNow = time();
foreach ($p_dbRows as $dbRow){
$showStartDateTime = DateHelper::ConvertToLocalDateTime($dbRow['show_starts']);
$showEndDateTime = DateHelper::ConvertToLocalDateTime($dbRow['show_ends']);
$itemStartDateTime = DateHelper::ConvertToLocalDateTime($dbRow['item_starts']);
$itemEndDateTime = DateHelper::ConvertToLocalDateTime($dbRow['item_ends']);
$showStarts = $showStartDateTime->format("Y-m-d H:i:s");
$showEnds = $showEndDateTime->format("Y-m-d H:i:s");
$itemStarts = $itemStartDateTime->format("Y-m-d H:i:s");
$itemEnds = $itemEndDateTime->format("Y-m-d H:i:s");
$status = ($dbRow['show_ends'] < $dbRow['item_ends']) ? "x" : "";
$type = "a";
$type .= ($dbRow['item_ends'] > $timeNow && $dbRow['item_starts'] <= $timeNow) ? "c" : "";
$type .= ($itemEndDateTime->getTimestamp() > $epochNow && $itemStartDateTime->getTimestamp() <= $epochNow) ? "c" : "";
// remove millisecond from the time format
$itemStart = explode('.', $dbRow['item_starts']);
@ -25,20 +35,20 @@ class Application_Model_Nowplaying
//format duration
$duration = explode('.', $dbRow['clip_length']);
$formated = Application_Model_Nowplaying::FormatDuration($duration[0]);
$dataTablesRows[] = array($type, $dbRow['show_starts'], $itemStart[0], $itemEnd[0],
$formated, $dbRow['track_title'], $dbRow['artist_name'], $dbRow['album_title'],
$formatted = self::FormatDuration($duration[0]);
$dataTablesRows[] = array($type, $showStarts, $itemStarts, $itemEnds,
$formatted, $dbRow['track_title'], $dbRow['artist_name'], $dbRow['album_title'],
$dbRow['playlist_name'], $dbRow['show_name'], $status);
}
return $dataTablesRows;
}
public static function CreateGapRow($p_gapTime){
private static function CreateGapRow($p_gapTime){
return array("g", "", "", "", $p_gapTime, "", "", "", "", "", "");
}
public static function CreateRecordingRow($p_showInstance){
private static function CreateRecordingRow($p_showInstance){
return array("r", "", "", "", $p_showInstance->getName(), "", "", "", "", "", "");
}
@ -71,21 +81,24 @@ class Application_Model_Nowplaying
$showId = $si->getShowId();
$show = new Show($showId);
$showStartDateTime = DateHelper::ConvertToLocalDateTime($si->getShowStart());
$showEndDateTime = DateHelper::ConvertToLocalDateTime($si->getShowEnd());
//append show header row
$data[] = Application_Model_Nowplaying::CreateHeaderRow($show->getName(), $si->getShowStart(), $si->getShowEnd());
$data[] = self::CreateHeaderRow($show->getName(), $showStartDateTime->format("Y-m-d H:i:s"), $showEndDateTime->format("Y-m-d H:i:s"));
$scheduledItems = $si->getScheduleItemsInRange($timeNow, $startCutoff, $endCutoff);
$dataTablesRows = Application_Model_Nowplaying::CreateDatatableRows($scheduledItems);
$dataTablesRows = self::CreateDatatableRows($scheduledItems);
//append show audio item rows
$data = array_merge($data, $dataTablesRows);
//append show gap time row
$gapTime = Application_Model_Nowplaying::FormatDuration($si->getShowEndGapTime(), true);
$gapTime = self::FormatDuration($si->getShowEndGapTime(), true);
if ($si->isRecorded())
$data[] = Application_Model_Nowplaying::CreateRecordingRow($si);
$data[] = self::CreateRecordingRow($si);
else if ($gapTime > 0)
$data[] = Application_Model_Nowplaying::CreateGapRow($gapTime);
$data[] = self::CreateGapRow($gapTime);
}
return array("currentShow"=>Show_DAL::GetCurrentShow($timeNow), "rows"=>$data);
@ -102,7 +115,7 @@ class Application_Model_Nowplaying
* default $time format should be in format of 00:00:00
* if $inSecond = true, then $time should be in seconds
*/
public static function FormatDuration($time, $inSecond=false){
private static function FormatDuration($time, $inSecond=false){
if($inSecond == false){
$duration = explode(':', $time);
}else{