Prevent division by zero if show lengths end up being zero
This commit is contained in:
parent
1577b7c41e
commit
fa0a190277
2 changed files with 12 additions and 5 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue