Update to core classes, see detail below
- config.inc: add define for show/not show all errors when parsning through Error.Handling.inc with SHOW_ALL_ERRORS - Error.Handling.inc: check php error level and do not show ones that are not flagged unless SHOW_ALL_ERRORS is set to true - db_pgsql.inc for fetch array, call the internal wrapper method, not the pg method directly - db_pgsql_pdo.inc: test insert for alternative with pdo lib instead of php internal postgresql interface - Class.DB.IO.inc: on prepared check if cursor exist before returing inserted id in INSERT queries. fail if no insert id could be aquired if there was no cursor (or other error) - Class.Basic.inc: rewrite Time to string method for speed up and removal of old php microtime format
This commit is contained in:
@@ -1036,32 +1036,27 @@
|
||||
// PARAMS: seconds
|
||||
// RETURN: formated time string
|
||||
// DESC: formats a timestamp into time from. not a date
|
||||
public static function TimeStringFormat($timestamp, $show_micro = 1)
|
||||
public static function TimeStringFormat($timestamp, $show_micro = true)
|
||||
{
|
||||
// check if the timestamp has any h/m/s/ms inside, if yes skip
|
||||
if (!preg_match("/(h|m|s|ms)/", $timestamp))
|
||||
{
|
||||
$ms = 0;
|
||||
// work on ms timestamp
|
||||
if (strstr($timestamp, " "))
|
||||
{
|
||||
list ($ms, $timestamp) = explode(" ", $timestamp);
|
||||
if (is_numeric($ms)) // special case round
|
||||
$ms = substr(round($ms, 4), 2);
|
||||
}
|
||||
else // if ms is as float
|
||||
{
|
||||
list ($timestamp, $ms) = explode('.', round($timestamp, 4));
|
||||
}
|
||||
$timegroups = array ("86400", "3600", "60", "1");
|
||||
$output = array ();
|
||||
list ($timestamp, $ms) = explode('.', round($timestamp, 4));
|
||||
$timegroups = array ('86400', '3600', '60', '1');
|
||||
$labels = array ('d', 'h', 'm', 's');
|
||||
$time_string = '';
|
||||
for ($i = 0; $i < count($timegroups); $i ++)
|
||||
{
|
||||
array_push($output, floor($timestamp / $timegroups[$i]));
|
||||
$output = floor($timestamp / $timegroups[$i]);
|
||||
$timestamp = $timestamp % $timegroups[$i];
|
||||
// output has days|hours|min|sec
|
||||
if ($output || $time_string)
|
||||
$time_string .= $output.$labels[$i].(($i + 1) != count($timegroups) ? ' ' : '');
|
||||
}
|
||||
# output has days|hours|min|sec(|ms)
|
||||
$time_string = (($output[0]) ? $output[0]."d " : "").(($output[1] || $output[0]) ? $output[1]."h " : "").(($output[2] ||$output[1] || $output[0]) ? $output[2]."m " : "").$output[3]."s".(($show_micro) ? " ".((!$ms) ? 0 : $ms)."ms" : "");
|
||||
// add ms if there
|
||||
if ($show_micro)
|
||||
$time_string .= ' '.(!$ms ? 0 : $ms).'ms';
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user