From 256ce00dde43987798e1ad234b6a8e8d50791d16 Mon Sep 17 00:00:00 2001 From: spiderr Date: Sun, 15 Jun 2025 02:04:57 -0400 Subject: fix strings without timezones using strtotime in cal_date_format --- smartyplugins/modifier.cal_date_format.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'smartyplugins') diff --git a/smartyplugins/modifier.cal_date_format.php b/smartyplugins/modifier.cal_date_format.php index 851573e..228d193 100644 --- a/smartyplugins/modifier.cal_date_format.php +++ b/smartyplugins/modifier.cal_date_format.php @@ -24,16 +24,20 @@ $gBitSmarty->loadPlugin('smarty_shared_make_timestamp'); */ function smarty_modifier_cal_date_format($string, $format = "%b %e, %Y", $default_date=null, $tra_format=null) { - $mDate = new BitDate(0); - if ( $mDate->get_display_offset()) $format = preg_replace("/ ?%Z/","",$format); - else $format = preg_replace("/%Z/","UTC",$format); + $mDate = new BitDate(); + if ( $mDate->get_display_offset()) { + $format = preg_replace("/ ?%Z/","",$format); + } else { + $format = preg_replace("/%Z/","UTC",$format); + } - $disptime = $mDate->getTimestampFromISO($string); + $disptime = strtotime( $string ); // Let PHP handle all conversion, TZ or not... global $gBitSystem, $gBitLanguage; //$gBitLanguage->mLanguage= $gBitSystem->getConfig("language", "en"); if ($gBitSystem->getConfig("language", "en") != $gBitLanguage->mLanguage && $tra_format) { $format = $tra_format; } + return $mDate->strftime($format, $disptime, true); } -- cgit v1.3