2012-03-01 17:25:37 +01:00
|
|
|
<?php
|
|
|
|
|
2012-08-29 16:58:03 +02:00
|
|
|
class TimeFilledFormatter
|
|
|
|
{
|
2012-03-01 17:25:37 +01:00
|
|
|
/**
|
|
|
|
* @string seconds
|
|
|
|
*/
|
|
|
|
private $_seconds;
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
// @param string $seconds
|
2012-03-01 17:25:37 +01:00
|
|
|
public function __construct($seconds)
|
|
|
|
{
|
|
|
|
$this->_seconds = $seconds;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function format()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$formatted = '';
|
|
|
|
$sign = ($this->_seconds < 0) ? '-' : '+';
|
2012-03-06 13:19:20 +01:00
|
|
|
$perfect = true;
|
2012-03-01 17:25:37 +01:00
|
|
|
|
2012-07-26 00:42:46 +02:00
|
|
|
$time = Application_Common_DateHelper::secondsToPlaylistTime(abs($this->_seconds));
|
2021-10-11 16:10:47 +02:00
|
|
|
$info = explode(':', $time);
|
2012-03-01 17:25:37 +01:00
|
|
|
|
|
|
|
$formatted .= $sign;
|
|
|
|
|
|
|
|
if (intval($info[0]) > 0) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$info[0] = ltrim($info[0], '0');
|
2012-03-01 17:25:37 +01:00
|
|
|
$formatted .= " {$info[0]}h";
|
2012-03-06 13:19:20 +01:00
|
|
|
$perfect = false;
|
2012-03-01 17:25:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (intval($info[1]) > 0) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$info[1] = ltrim($info[1], '0');
|
2012-03-01 17:25:37 +01:00
|
|
|
$formatted .= " {$info[1]}m";
|
2012-03-06 13:19:20 +01:00
|
|
|
$perfect = false;
|
2012-03-01 17:25:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (intval($info[2]) > 0) {
|
|
|
|
$sec = round($info[2], 0);
|
|
|
|
$formatted .= " {$sec}s";
|
2012-03-06 13:19:20 +01:00
|
|
|
$perfect = false;
|
|
|
|
}
|
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// 0 over/under lap of content.
|
2012-03-06 13:19:20 +01:00
|
|
|
if ($perfect === true) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$formatted = '+ 0s';
|
2012-03-01 17:25:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return $formatted;
|
|
|
|
}
|
2012-08-29 16:58:03 +02:00
|
|
|
}
|