X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/87a40bf7dc910c008aa6aadf8882b070ad120c39..cdd2e058776a3d0dc9b6f32a2d5d33e4f9388491:/WEB-INF/lib/ttTimeHelper.class.php diff --git a/WEB-INF/lib/ttTimeHelper.class.php b/WEB-INF/lib/ttTimeHelper.class.php index 3cef8b44..0d5863ed 100644 --- a/WEB-INF/lib/ttTimeHelper.class.php +++ b/WEB-INF/lib/ttTimeHelper.class.php @@ -173,7 +173,7 @@ class ttTimeHelper { // minutesToDuration converts an integer number of minutes into duration string. // Formats returned HH:MM, HHH:MM, HH, or HHH. static function minutesToDuration($minutes, $abbreviate = false) { - $sign = $minutes > 0 ? '' : '-'; + $sign = $minutes >= 0 ? '' : '-'; $minutes = abs($minutes); $hours = (string) (int)($minutes / 60); @@ -188,8 +188,11 @@ class ttTimeHelper { // toMinutes - converts a time string in format 00:00 to a number of minutes. static function toMinutes($value) { + $signMultiplier = ttStartsWith($value, '-') ? -1 : 1; + if ($signMultiplier == -1) $duration = ltrim($duration, '-'); + $time_a = explode(':', $value); - return (int)@$time_a[1] + ((int)@$time_a[0]) * 60; + return $signMultiplier * ((int)@$time_a[1] + ((int)@$time_a[0]) * 60); } // toAbsDuration - converts a number of minutes to format 0:00 @@ -804,11 +807,12 @@ class ttTimeHelper { } // getRecords - returns time records for a user for a given date. - static function getRecords($user_id, $date) { + static function getRecords($date) { // TODO: merge getRecords and getRecordsWithFiles into one function. global $user; $mdb2 = getConnection(); + $user_id = $user->getUser(); $group_id = $user->getGroup(); $org_id = $user->org_id; @@ -866,10 +870,11 @@ class ttTimeHelper { // getRecordsWithFiles - returns time records for a user for a given date // with information whether they have attached files (has_files property). // A separate fiunction from getRecords because sql here is more complex. - static function getRecordsWithFiles($user_id, $date) { + static function getRecordsWithFiles($date) { global $user; $mdb2 = getConnection(); + $user_id = $user->getUser(); $group_id = $user->getGroup(); $org_id = $user->org_id;