CC-5627 : Check all Application_Common_DateHelper calculations that use timezone

This commit is contained in:
Naomi 2013-12-13 15:03:02 -05:00
parent 1dfcfd3e34
commit a45235d39b
1 changed files with 7 additions and 2 deletions

View File

@ -1056,11 +1056,16 @@ SQL;
/**
* Calculates the percentage of a show scheduled given the start and end times in date/time format
* and the time_filled as the total time the schow is scheduled for in time format.
*
* TODO when using propel properly this should be a method on the propel show instance model.
**/
private static function getPercentScheduled($p_starts, $p_ends, $p_time_filled)
{
$durationSeconds = (strtotime($p_ends) - strtotime($p_starts));
$time_filled = Application_Model_Schedule::WallTimeToMillisecs($p_time_filled) / 1000;
$utcTimezone = new DatetimeZone("UTC");
$startDt = new DateTime($p_starts, $utcTimezone);
$endDt = new DateTime($p_ends, $utcTimezone);
$durationSeconds = intval($endDt->format("U")) - intval($startDt->format("U"));
$time_filled = Application_Common_DateHelper::playlistTimeToSeconds($p_time_filled);
$percent = ceil(( $time_filled / $durationSeconds) * 100);
return $percent;