X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/7ddf5c391598126ec473db7b25884ee0bd94f153..809672af61a5feba4c8daa8c2f4b62e64177fc2b:/WEB-INF/lib/common.lib.php diff --git a/WEB-INF/lib/common.lib.php b/WEB-INF/lib/common.lib.php index 124b78f5..167b95b2 100644 --- a/WEB-INF/lib/common.lib.php +++ b/WEB-INF/lib/common.lib.php @@ -143,15 +143,17 @@ } } -function time_to_decimal($a) { - $tmp = explode(":", $a); - if($tmp[1]{0}=="0") $tmp[1] = $tmp[1]{1}; +// time_to_decimal converts a time string such as 1:15 to its decimal representation such as 1.25 or 1,25. +function time_to_decimal($val) { + global $user; + $parts = explode(':', $val); // parts[0] is hours, parts[1] is minutes. + + $minutePercent = round($parts[1]*100/60); // Integer value (0-98) of percent of minutes portion in the hour. + if($minutePercent < 10) $minutePercent = '0'.$minutePercent; // Pad small values with a 0 to always have 2 digits. - $m = round($tmp[1]*100/60); + $decimalTime = $parts[0].$user->decimal_mark.$minutePercent; // Construct decimal representation of time value. - if($m<10) $m = "0".$m; - $time = $tmp[0].".".$m; - return $time; + return $decimalTime; } function sec_to_time_fmt_hm($sec)