Prevent division by zero if show lengths end up being zero

This commit is contained in:
Albert Santoni 2013-12-13 16:10:36 -05:00
parent 1577b7c41e
commit fa0a190277
2 changed files with 12 additions and 5 deletions

View file

@ -1061,8 +1061,12 @@ SQL;
{
$durationSeconds = (strtotime($p_ends) - strtotime($p_starts));
$time_filled = Application_Model_Schedule::WallTimeToMillisecs($p_time_filled) / 1000;
$percent = ceil(( $time_filled / $durationSeconds) * 100);
if ($durationSeconds != 0) { //Prevent division by zero if zero length show occurs.
$percent = ceil(( $time_filled / $durationSeconds) * 100);
} else {
$percent = 0;
}
return $percent;
}

View file

@ -551,8 +551,11 @@ SQL;
$durationSeconds = $this->getDurationSecs();
$timeSeconds = $this->getTimeScheduledSecs();
if ($durationSeconds != 0) { //Prevent division by zero if the show duration is somehow zero.
$percent = ceil(($timeSeconds / $durationSeconds) * 100);
} else {
$percent = 0;
}
return $percent;
}