Blame www/smarty/plugins/modifier.date_format.php
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
/**
|
|
Chris PeBenito |
696b41 |
* Smarty plugin
|
|
Chris PeBenito |
696b41 |
* @package Smarty
|
|
Chris PeBenito |
696b41 |
* @subpackage plugins
|
|
Chris PeBenito |
696b41 |
*/
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
/**
|
|
Chris PeBenito |
696b41 |
* Include the {@link shared.make_timestamp.php} plugin
|
|
Chris PeBenito |
696b41 |
*/
|
|
Chris PeBenito |
696b41 |
require_once $smarty->_get_plugin_filepath('shared','make_timestamp');
|
|
Chris PeBenito |
696b41 |
/**
|
|
Chris PeBenito |
696b41 |
* Smarty date_format modifier plugin
|
|
Chris PeBenito |
696b41 |
*
|
|
Chris PeBenito |
696b41 |
* Type: modifier
|
|
Chris PeBenito |
696b41 |
* Name: date_format
|
|
Chris PeBenito |
696b41 |
* Purpose: format datestamps via strftime
|
|
Chris PeBenito |
696b41 |
* Input:
|
|
Chris PeBenito |
696b41 |
* - string: input date string
|
|
Chris PeBenito |
696b41 |
* - format: strftime format for output
|
|
Chris PeBenito |
696b41 |
* - default_date: default date if $string is empty
|
|
Chris PeBenito |
696b41 |
* @link http://smarty.php.net/manual/en/language.modifier.date.format.php
|
|
Chris PeBenito |
696b41 |
* date_format (Smarty online manual)
|
|
Chris PeBenito |
696b41 |
* @param string
|
|
Chris PeBenito |
696b41 |
* @param string
|
|
Chris PeBenito |
696b41 |
* @param string
|
|
Chris PeBenito |
696b41 |
* @return string|void
|
|
Chris PeBenito |
696b41 |
* @uses smarty_make_timestamp()
|
|
Chris PeBenito |
696b41 |
*/
|
|
Chris PeBenito |
696b41 |
function smarty_modifier_date_format($string, $format="%b %e, %Y", $default_date=null)
|
|
Chris PeBenito |
696b41 |
{
|
|
Chris PeBenito |
696b41 |
if (substr(PHP_OS,0,3) == 'WIN') {
|
|
Chris PeBenito |
696b41 |
$_win_from = array ('%e', '%T', '%D');
|
|
Chris PeBenito |
696b41 |
$_win_to = array ('%#d', '%H:%M:%S', '%m/%d/%y');
|
|
Chris PeBenito |
696b41 |
$format = str_replace($_win_from, $_win_to, $format);
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
if($string != '') {
|
|
Chris PeBenito |
696b41 |
return strftime($format, smarty_make_timestamp($string));
|
|
Chris PeBenito |
696b41 |
} elseif (isset($default_date) && $default_date != '') {
|
|
Chris PeBenito |
696b41 |
return strftime($format, smarty_make_timestamp($default_date));
|
|
Chris PeBenito |
696b41 |
} else {
|
|
Chris PeBenito |
696b41 |
return;
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
/* vim: set expandtab: */
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
?>
|