From 4b1d586ef0b6fee63b02e5df624ac43c303ef2a7 Mon Sep 17 00:00:00 2001 From: Luis Calvo Date: Thu, 16 Jul 2020 14:07:29 +0200 Subject: [PATCH] Fixed and added strfdate formats --- pandora_console/include/functions.php | 32 +++++++++++++++++++++--- pandora_console/include/functions_ui.php | 3 ++- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 23773a2934..ae906dccce 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -3209,7 +3209,7 @@ function get_refresh_time_array() } -function date2strftime_format($date_format) +function date2strftime_format($date_format, $timestamp=null) { $replaces_list = [ 'D' => '%a', @@ -3232,11 +3232,14 @@ function date2strftime_format($date_format) 'A' => '%p', 'i' => '%M', 's' => '%S', - 'u' => '%s', 'O' => '%z', 'T' => '%Z', '%' => '%%', 'G' => '%k', + 'z' => '%j', + 'U' => '%s', + 'c' => '%FT%T%z', + 'r' => '%d %b %Y %H:%M:%S %z', ]; $return = ''; @@ -3249,7 +3252,30 @@ function date2strftime_format($date_format) if (isset($replaces_list[$c])) { $return .= $replaces_list[$c]; } else { - $return .= $c; + // Check extra formats. + switch ($date_format) { + default: $return .= date($date_format, $timestamp); + break; + + case 'n': + if (stristr(PHP_OS, 'win')) { + $return .= '%#m'; + } else { + $return .= '%-m'; + } + + case 'u': + if (preg_match('/^[0-9]*\\.([0-9]+)$/', $timestamp, $reg)) { + $decimal = substr(str_pad($reg[1], 6, '0'), 0, 6); + } else { + $decimal = '000000'; + } + + $return .= $decimal; + break; + + break; + } } } diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 16f3319a06..85e5d91c96 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -541,8 +541,9 @@ function ui_print_timestamp($unixtime, $return=false, $option=[]) pandora_setlocale(); $title = human_time_comparation($unixtime); + $strf_format = date2strftime_format($config['date_format'], $unixtime); $data = strftime( - date2strftime_format($config['date_format']), + $strf_format, $unixtime ); } else if ($prominent == 'compact') {