From: Nik Okuntseff Date: Thu, 21 Jul 2016 16:41:41 +0000 (+0000) Subject: Refactoring - renamed a function for clarity of purpose. X-Git-Tag: timetracker_1.19-1~1690 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=fb177d58cddc49dcc9507bfa75ab78732571eef9;p=timetracker.git Refactoring - renamed a function for clarity of purpose. --- diff --git a/WEB-INF/lib/ttTimeHelper.class.php b/WEB-INF/lib/ttTimeHelper.class.php index f98d6757..a6117eef 100644 --- a/WEB-INF/lib/ttTimeHelper.class.php +++ b/WEB-INF/lib/ttTimeHelper.class.php @@ -146,8 +146,9 @@ class ttTimeHelper { return (int)@$time_a[1] + ((int)@$time_a[0]) * 60; } - // fromMinutes - converts a number of minutes to format 00:00 - static function fromMinutes($minutes){ + // toAbsDuration - converts a number of minutes to format 00:00 + // even if $minutes is negative. + static function toAbsDuration($minutes){ $hours = (string)((int)abs($minutes / 60)); $mins = (string)(abs($minutes % 60)); if (strlen($hours) == 1) @@ -162,7 +163,7 @@ class ttTimeHelper { $duration_minutes = ttTimeHelper::toMinutes($finish) - ttTimeHelper::toMinutes($start); if ($duration_minutes <= 0) return false; - return ttTimeHelper::fromMinutes($duration_minutes); + return ttTimeHelper::toAbsDuration($duration_minutes); } // The to12HourFormat function converts a 24-hour time value (such as 15:23) to 12 hour format (03:23 PM). diff --git a/time.php b/time.php index 33b57639..63290a69 100644 --- a/time.php +++ b/time.php @@ -72,7 +72,7 @@ if ($user->isPluginEnabled('mq')){ $smarty->assign('month_total', $month_total); $smarty->assign('over_quota', $minutesLeft < 0); - $smarty->assign('month_left', ttTimeHelper::fromMinutes($minutesLeft)); + $smarty->assign('month_left', ttTimeHelper::toAbsDuration($minutesLeft)); } // Initialize variables.