Add new function for parsing dates
[platal.git] / plugins / modifier.date_format.php
index 7a5c64b..a2e5bec 100644 (file)
@@ -25,23 +25,8 @@ function smarty_modifier_date_format($string, $format = '%x', $default_date=null
     if (empty($format) || preg_match('/^[ 0\-]*$/', $d)) return;
     $f = str_replace('%X', '%T', str_replace('%x', '%e %B %Y', $format));
 
-    if (preg_match('/^\d{14}$/', $d)) {
-        $t = mktime(substr($d,8,2), substr($d,10,2), substr($d,12,2), substr($d,4,2), substr($d,6,2), substr($d,0,4));
-    } elseif (preg_match('/^\d{8}$/', $d)) {
-        $t = mktime(0, 0, 0, substr($d,4,2), substr($d,6,2), substr($d,0,4));
-    } elseif (is_numeric($d)) {
-        $t = intval($d);
-    } else {
-        $t = strtotime($d);
-    }
-
-    if ( $t != -1 ) {
-        return strftime($f , $t);
-    } else {
-        require_once('Date.php');
-        $date = new Date($d);
-        return $date->format($f);
-    }
+    $d = make_datetime($d);
+    return $d->format($f);
 }
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: