Cosmetic - testing basic branching and merges.
[timetracker.git] / WEB-INF / lib / common.lib.php
index 4111c3e..13a5d13 100644 (file)
                }
        }
 
-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