PageRenderTime 7ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/framework/vendor/smarty2/lib/plugins/modifier.date_format.php

http://zoop.googlecode.com/
PHP | 49 lines | 18 code | 3 blank | 28 comment | 7 complexity | 9c0102288dc388c9862f19e9df20635a MD5 | raw file
 1<?php
 2/**
 3 * Smarty plugin
 4 * @package Smarty
 5 * @subpackage plugins
 6 */
 7
 8/**
 9 * Include the {@link shared.make_timestamp.php} plugin
10 */
11require_once $smarty->_get_plugin_filepath('shared','make_timestamp');
12/**
13 * Smarty date_format modifier plugin
14 *
15 * Type:     modifier<br>
16 * Name:     date_format<br>
17 * Purpose:  format datestamps via strftime<br>
18 * Input:<br>
19 *         - string: input date string
20 *         - format: strftime format for output
21 *         - default_date: default date if $string is empty
22 * @link http://smarty.php.net/manual/en/language.modifier.date.format.php
23 *          date_format (Smarty online manual)
24 * @author   Monte Ohrt <monte at ohrt dot com>
25 * @param string
26 * @param string
27 * @param string
28 * @return string|void
29 * @uses smarty_make_timestamp()
30 */
31function smarty_modifier_date_format($string, $format="%b %e, %Y", $default_date=null)
32{
33    if (substr(PHP_OS,0,3) == 'WIN') {
34           $_win_from = array ('%e',  '%T',       '%D');
35           $_win_to   = array ('%#d', '%H:%M:%S', '%m/%d/%y');
36           $format = str_replace($_win_from, $_win_to, $format);
37    }
38    if($string != '') {
39        return strftime($format, smarty_make_timestamp($string));
40    } elseif (isset($default_date) && $default_date != '') {
41        return strftime($format, smarty_make_timestamp($default_date));
42    } else {
43        return;
44    }
45}
46
47/* vim: set expandtab: */
48
49?>