Allow localization of date formating
This commit is contained in:
@@ -50,6 +50,7 @@ class Format extends AbstractSmartyPlugin
|
|||||||
*
|
*
|
||||||
* ex :
|
* ex :
|
||||||
* {format_date date=$dateTimeObject format="Y-m-d H:i:s"} will output the format with specific format
|
* {format_date date=$dateTimeObject format="Y-m-d H:i:s"} will output the format with specific format
|
||||||
|
* {format_date date=$dateTimeObject format="% %B %Y" locale="fr_FR"} will output the format with specific format
|
||||||
* {format_date date=$dateTimeObject output="date"} will output the date using the default date system format
|
* {format_date date=$dateTimeObject output="date"} will output the date using the default date system format
|
||||||
* {format_date date=$dateTimeObject} will output with the default datetime system format
|
* {format_date date=$dateTimeObject} will output with the default datetime system format
|
||||||
*
|
*
|
||||||
@@ -86,7 +87,15 @@ class Format extends AbstractSmartyPlugin
|
|||||||
$format = DateTimeFormat::getInstance($this->request)->getFormat($this->getParam($params, "output", null));
|
$format = DateTimeFormat::getInstance($this->request)->getFormat($this->getParam($params, "output", null));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $date->format($format);
|
$locale = $this->getParam($params,'locale', false);
|
||||||
|
|
||||||
|
if($locale === false)
|
||||||
|
{
|
||||||
|
return $date->format($format);
|
||||||
|
} else {
|
||||||
|
setlocale('LC_TIME', $locale);
|
||||||
|
return strftime($format, $date->getTimestamp());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -171,4 +180,4 @@ class Format extends AbstractSmartyPlugin
|
|||||||
new SmartyPluginDescriptor("function", "format_money", $this, "formatMoney")
|
new SmartyPluginDescriptor("function", "format_money", $this, "formatMoney")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user