use gmdate

This commit is contained in:
Steffen Schröder 2014-06-15 02:50:13 +02:00
parent a400573625
commit e94bf2ec05
3 changed files with 5 additions and 23 deletions

View File

@ -237,7 +237,7 @@ class PlayerDetailed {
$statProperties = $stat[0];
if ($statProperties->type === StatisticManager::STAT_TYPE_TIME) {
$value = Formatter::formatTimeHMS($value);
$value = Formatter::formatTimeH($value);
} else if ($statProperties->type === StatisticManager::STAT_TYPE_FLOAT) {
$value = round($value, 2);
}

View File

@ -243,7 +243,7 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
if (isset($statRankings[$stat['Name']][$playerId])) {
$statValue = $statRankings[$stat['Name']][$playerId];
if ($stat['Format'] == StatisticManager::STAT_TYPE_TIME) {
$statValue = Formatter::formatTimeHMS($statValue);
$statValue = Formatter::formatTimeH($statValue);
} else if ($stat['Format'] == StatisticManager::STAT_TYPE_FLOAT) {
$statValue = round(floatval($statValue), 2);
}

View File

@ -28,6 +28,7 @@ abstract class Formatter {
* @return string
*/
public static function formatTime($time) {
// TODO: use gmdate()
$time = (int)$time;
$milliseconds = $time % 1000;
$seconds = floor($time / 1000);
@ -42,25 +43,6 @@ abstract class Formatter {
return $format;
}
/**
* Format a Time to H:M:S
*
* @param int $seconds
* @return string
*/
public static function formatTimeHMS($seconds) {
$minutes = floor($seconds / 60);
$hours = floor($minutes / 60);
$minutes -= $hours * 60;
$seconds -= ($hours * 3600 + $minutes * 60);
$hours = ($hours < 10 ? '0' : '') . $hours;
$minutes = ($minutes < 10 ? '0' : '') . $minutes;;
$seconds = ($seconds < 10 ? '0' : '') . $seconds;;
return $hours . ":" . $minutes . ":" . $seconds;
}
/**
* Format an elapsed time String (2 days ago...) by a given timestamp
*
@ -94,7 +76,7 @@ abstract class Formatter {
* @return string
*/
public static function formatTimeH($seconds) {
return date("H:i:s", $seconds);
return gmdate('H:i:s', $seconds);
}
/**
@ -104,7 +86,7 @@ abstract class Formatter {
* @return string
*/
public static function formatTimestamp($seconds) {
return date("Y-m-d H:i:s", $seconds);
return date('Y-m-d H:i:s', $seconds);
}
/**