Changeset 4906 for OpenPNE/trunk
- Timestamp:
- Jan 11, 2008, 1:38:50 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
OpenPNE/trunk/lib/smarty_plugins/modifier.date_format.php
r4884 r4906 8 8 * Include the {@link shared.make_timestamp.php} plugin 9 9 */ 10 require_once $smarty->_get_plugin_filepath('shared', 'make_timestamp');10 require_once $smarty->_get_plugin_filepath('shared', 'make_timestamp'); 11 11 /** 12 12 * Smarty date_format modifier plugin … … 28 28 * @uses smarty_make_timestamp() 29 29 */ 30 function smarty_modifier_date_format($string, $format = '%m/%d', $default_date = null)30 function smarty_modifier_date_format($string, $format = '%m/%d', $default_date = '') 31 31 { 32 if (!($ts = smarty_make_timestamp($string)) 33 && ((empty($default_date) || !$ts = smarty_make_timestamp($default_date)))) { 32 if ($string != '') { 33 $timestamp = smarty_make_timestamp($string); 34 } elseif ($default_date != '') { 35 $timestamp = smarty_make_timestamp($default_date); 36 } else { 34 37 return; 35 38 } 36 37 39 if (DIRECTORY_SEPARATOR == '\\') { 38 40 $_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T'); … … 40 42 if (strpos($format, '%e') !== false) { 41 43 $_win_from[] = '%e'; 42 $_win_to[] = sprintf('%\' 2d', date('j', $t s));44 $_win_to[] = sprintf('%\' 2d', date('j', $timestamp)); 43 45 } 44 46 if (strpos($format, '%l') !== false) { 45 47 $_win_from[] = '%l'; 46 $_win_to[] = sprintf('%\' 2d', date('h', $t s));48 $_win_to[] = sprintf('%\' 2d', date('h', $timestamp)); 47 49 } 48 50 $format = str_replace($_win_from, $_win_to, $format); 49 51 } 50 51 52 return preg_replace_callback('/\%[a-z\%]/iu', 52 create_function('$res', 'return strftime($res[0], '.$t s.');'),53 create_function('$res', 'return strftime($res[0], '.$timestamp.');'), 53 54 $format); 54 55 }
Note: See TracChangeset
for help on using the changeset viewer.