mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-06 19:34:27 +02:00
add automagic formatting for date() and strftime()
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
* @return string |void
|
||||
* @uses smarty_make_timestamp()
|
||||
*/
|
||||
function smarty_modifier_date_format($string, $format = SMARTY_RESOURCE_DATE_FORMAT, $default_date = '')
|
||||
function smarty_modifier_date_format($string, $format = SMARTY_RESOURCE_DATE_FORMAT, $default_date = '',$formatter='auto')
|
||||
{
|
||||
/**
|
||||
* Include the {@link shared.make_timestamp.php} plugin
|
||||
@@ -38,6 +38,7 @@ function smarty_modifier_date_format($string, $format = SMARTY_RESOURCE_DATE_FOR
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
if($formatter=='strftime'||($formatter=='auto'&&strpos($format,'%')!==false)) {
|
||||
if (DS == '\\') {
|
||||
$_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T');
|
||||
$_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S');
|
||||
@@ -52,6 +53,9 @@ function smarty_modifier_date_format($string, $format = SMARTY_RESOURCE_DATE_FOR
|
||||
$format = str_replace($_win_from, $_win_to, $format);
|
||||
}
|
||||
return strftime($format, $timestamp);
|
||||
} else {
|
||||
return date($format, $timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
Reference in New Issue
Block a user