Хранилища Subversion ant

Редакция

Содержимое файла | Последнее изменение | Открыть журнал | RSS

Редакция Автор № строки Строка
304 alex-w 1
<?php
2
/**
3
* Smarty plugin
4
*
5
* @package Smarty
6
* @subpackage PluginsModifier
7
*/
8
 
9
/**
10
* Smarty date_format modifier plugin
11
*
12
* Type:     modifier<br>
13
* Name:     date_format<br>
14
* Purpose:  format datestamps via strftime<br>
15
* Input:<br>
16
*          - string: input date string
17
*          - format: strftime format for output
18
*          - default_date: default date if $string is empty
19
*
20
* @link http://smarty.php.net/manual/en/language.modifier.date.format.php date_format (Smarty online manual)
21
* @author Monte Ohrt <monte at ohrt dot com>
22
* @param string $
23
* @param string $
24
* @param string $
25
* @return string |void
26
* @uses smarty_make_timestamp()
27
*/
28
function smarty_modifier_date_format($string, $format = '%b %e, %Y', $default_date = '')
29
{
30
    /**
31
    * Include the {@link shared.make_timestamp.php} plugin
32
    */
33
    require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
34
    if ($string != '') {
35
        $timestamp = smarty_make_timestamp($string);
36
    } elseif ($default_date != '') {
37
        $timestamp = smarty_make_timestamp($default_date);
38
    } else {
39
        return;
40
    }
41
    if (DS == '\\') {
42
        $_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T');
43
        $_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S');
44
        if (strpos($format, '%e') !== false) {
45
            $_win_from[] = '%e';
46
            $_win_to[] = sprintf('%\' 2d', date('j', $timestamp));
47
        }
48
        if (strpos($format, '%l') !== false) {
49
            $_win_from[] = '%l';
50
            $_win_to[] = sprintf('%\' 2d', date('h', $timestamp));
51
        }
52
        $format = str_replace($_win_from, $_win_to, $format);
53
    }
54
    return strftime($format, $timestamp);
55
}
56
 
57
?>