X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/e20813a282b957d4b9112b825f87502c3525a780..88ea8b988a90105b46ac7dd1e53dc8c99de3880c:/WEB-INF/lib/common.lib.php diff --git a/WEB-INF/lib/common.lib.php b/WEB-INF/lib/common.lib.php index d98e8889..4fa43777 100644 --- a/WEB-INF/lib/common.lib.php +++ b/WEB-INF/lib/common.lib.php @@ -26,13 +26,8 @@ // | https://www.anuko.com/time_tracker/credits.htm // +----------------------------------------------------------------------+ - /** - * @return unknown - * @param file unknown - * @param version = "" unknown - * @desc Loads a class - */ - function import( $class_name ) { +// import() function loads a class. +function import($class_name) { $libs = array( dirname($_SERVER["SCRIPT_FILENAME"]), LIBRARY_DIR @@ -61,7 +56,7 @@ print '
load_class: error loading file "'.$filename.'"'; die(); - } +} // The mu_sort function is used to sort a multi-dimensional array. // It looks like the code example is taken from the PHP manual http://ca2.php.net/manual/en/function.sort.php @@ -143,16 +138,17 @@ } } -function time_to_decimal($a) { +// 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; - $tmp = explode(":", $a); - if($tmp[1]{0}=="0") $tmp[1] = $tmp[1]{1}; + $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].$user->decimal_mark.$m; - return $time; + return $decimalTime; } function sec_to_time_fmt_hm($sec)