Fixed and added strfdate formats

This commit is contained in:
Luis Calvo 2020-07-16 14:07:29 +02:00
parent d9ceb1d554
commit 4b1d586ef0
2 changed files with 31 additions and 4 deletions

View File

@ -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;
}
}
}

View File

@ -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') {