X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=WEB-INF%2Flib%2Fcommon.lib.php;h=13a5d13c05fd8a1bf2996c57f70dbf02e55136ae;hb=8015002a4a219b8fe8a62c95d7561284db5ae07c;hp=4111c3e159102af6d75e8c3e6c3468c9a85837b1;hpb=9a23a8c0a51b7ec38a96f525484134f3cb85dc7e;p=timetracker.git diff --git a/WEB-INF/lib/common.lib.php b/WEB-INF/lib/common.lib.php index 4111c3e1..13a5d13c 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) @@ -161,11 +163,9 @@ function sec_to_time_fmt_hm($sec) function magic_quotes_off() { - // if (get_magic_quotes_gpc()) { // This check is now done before calling this function. - $_POST = array_map('stripslashes_deep', $_POST); - $_GET = array_map('stripslashes_deep', $_GET); - $_COOKIE = array_map('stripslashes_deep', $_COOKIE); - // } + $_POST = array_map('stripslashes_deep', $_POST); + $_GET = array_map('stripslashes_deep', $_GET); + $_COOKIE = array_map('stripslashes_deep', $_COOKIE); } // check_extension checks whether a required PHP extension is loaded and dies if not so. @@ -340,12 +340,3 @@ function ttAccessCheck($required_rights) return true; } - - - - - - - - -?> \ No newline at end of file