From e94bf2ec054b6187eabd07e1775af76fc0fa41dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Sun, 15 Jun 2014 02:50:13 +0200 Subject: [PATCH] use gmdate --- application/core/Players/PlayerDetailed.php | 2 +- .../core/Statistics/SimpleStatsList.php | 2 +- application/core/Utils/Formatter.php | 24 +++---------------- 3 files changed, 5 insertions(+), 23 deletions(-) diff --git a/application/core/Players/PlayerDetailed.php b/application/core/Players/PlayerDetailed.php index 31d919d4..3a82d46d 100644 --- a/application/core/Players/PlayerDetailed.php +++ b/application/core/Players/PlayerDetailed.php @@ -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); } diff --git a/application/core/Statistics/SimpleStatsList.php b/application/core/Statistics/SimpleStatsList.php index a6532592..1800ce09 100644 --- a/application/core/Statistics/SimpleStatsList.php +++ b/application/core/Statistics/SimpleStatsList.php @@ -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); } diff --git a/application/core/Utils/Formatter.php b/application/core/Utils/Formatter.php index faabd65a..e908179d 100644 --- a/application/core/Utils/Formatter.php +++ b/application/core/Utils/Formatter.php @@ -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); } /**