summaryrefslogtreecommitdiff
path: root/lib/smarty3/plugins/modifier.date_format.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/smarty3/plugins/modifier.date_format.php')
-rw-r--r--lib/smarty3/plugins/modifier.date_format.php46
1 files changed, 33 insertions, 13 deletions
diff --git a/lib/smarty3/plugins/modifier.date_format.php b/lib/smarty3/plugins/modifier.date_format.php
index 28d6ff0..23b6943 100644
--- a/lib/smarty3/plugins/modifier.date_format.php
+++ b/lib/smarty3/plugins/modifier.date_format.php
@@ -5,13 +5,12 @@
* @package Smarty
* @subpackage PluginsModifier
*/
-
/**
* Smarty date_format modifier plugin
- * Type: modifier<br>
- * Name: date_format<br>
- * Purpose: format datestamps via strftime<br>
- * Input:<br>
+ * Type: modifier
+ * Name: date_format
+ * Purpose: format datestamps via strftime
+ * Input:
* - string: input date string
* - format: strftime format for output
* - default_date: default date if $string is empty
@@ -35,18 +34,40 @@ function smarty_modifier_date_format($string, $format = null, $default_date = ''
/**
* require_once the {@link shared.make_timestamp.php} plugin
*/
- require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
- if ($string != '' && $string != '0000-00-00' && $string != '0000-00-00 00:00:00') {
+ static $is_loaded = false;
+ if (!$is_loaded) {
+ if (!is_callable('smarty_make_timestamp')) {
+ include_once SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php';
+ }
+ $is_loaded = true;
+ }
+ if ($string !== '' && $string !== '0000-00-00' && $string !== '0000-00-00 00:00:00') {
$timestamp = smarty_make_timestamp($string);
- } elseif ($default_date != '') {
+ } elseif ($default_date !== '') {
$timestamp = smarty_make_timestamp($default_date);
} 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');
+ if ($formatter === 'strftime' || ($formatter === 'auto' && strpos($format, '%') !== false)) {
+ if (Smarty::$_IS_WINDOWS) {
+ $_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'
+ );
if (strpos($format, '%e') !== false) {
$_win_from[] = '%e';
$_win_to[] = sprintf('%\' 2d', date('j', $timestamp));
@@ -57,7 +78,6 @@ function smarty_modifier_date_format($string, $format = null, $default_date = ''
}
$format = str_replace($_win_from, $_win_to, $format);
}
-
return strftime($format, $timestamp);
} else {
return date($format, $timestamp);