cvs: smarty / NEWS /docs/en/designers/language-modifiers language-modifier-date-format.xml /libs/internals core.write_file.php /libs/plugins modifier.date_format.php
[email protected] ("Danilo Buerger") Tue, 27 Feb 2007 22:22:09 -0000
| Newsgroups | php.smarty.cvs |
|---|---|
| Message-ID | <cvsdanilo1172614929@cvsserver> |
danilo Tue Feb 27 22:22:09 2007 UTC
Modified files:
/smarty NEWS
/smarty/docs/en/designers/language-modifiers
language-modifier-date-format.xml
/smarty/libs/internals core.write_file.php
/smarty/libs/plugins modifier.date_format.php
Log:
Updated smarty_core_write_file() and smarty_modifier_date_format() to speed up Windows detection.
Emulated more parameters for Windows in smarty_modifier_date_format() and fixed some old ones.
Updated the docs to tell what parameters are emulated on Windows.
Updated NEWS file.
http://cvs.php.net/viewvc.cgi/smarty/NEWS?r1=1.550&r2=1.551&diff_format=u
Index: smarty/NEWS
diff -u smarty/NEWS:1.550 smarty/NEWS:1.551
--- smarty/NEWS:1.550 Tue Feb 27 18:35:00 2007
+++ smarty/NEWS Tue Feb 27 22:22:09 2007
@@ -3,8 +3,10 @@
than $length (Sylvinus, messju)
- fix handling of %I with mysql timestamps in the date_format modifier
(danilo, boots)
-- update smarty_core_write_file() to better recognize Windows (boots)
-- emulate %R in the date_format modifier on Windows (danilo, boots)
+- update smarty_core_write_file() and smarty_modifier_date_format() to better
+ recognize Windows (boots, danilo)
+- emulate %h, %n, %r, %R, %t in the date_format modifier on Windows
+ (danilo, boots)
Version 2.6.16 (Dec 1st, 2006)
-------------------------------
http://cvs.php.net/viewvc.cgi/smarty/docs/en/designers/language-modifiers/language-modifier-date-format.xml?r1=1.14&r2=1.15&diff_format=u
Index: smarty/docs/en/designers/language-modifiers/language-modifier-date-format.xml
diff -u smarty/docs/en/designers/language-modifiers/language-modifier-date-format.xml:1.14 smarty/docs/en/designers/language-modifiers/language-modifier-date-format.xml:1.15
--- smarty/docs/en/designers/language-modifiers/language-modifier-date-format.xml:1.14 Tue Sep 26 19:28:45 2006
+++ smarty/docs/en/designers/language-modifiers/language-modifier-date-format.xml Tue Feb 27 22:22:09 2007
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.14 $ -->
+<!-- $Revision: 1.15 $ -->
<sect1 id="language.modifier.date.format">
<title>date_format</title>
<para>
@@ -79,7 +79,9 @@
You may have more or less conversion specifiers available depending
on your system's <ulink url="&url.php-manual;strftime"><varname>strftime()</varname></ulink>
function where PHP was compiled. Check your
- system's manpage for a full list of valid specifiers.
+ system's manpage for a full list of valid specifiers. However, a few of
+ the specifiers are emulated on Windows. These are: %D, %e, %h, %l, %n,
+ %r, %R, %t, %T.
</para>
</note>
</para>
http://cvs.php.net/viewvc.cgi/smarty/libs/internals/core.write_file.php?r1=1.4&r2=1.5&diff_format=u
Index: smarty/libs/internals/core.write_file.php
diff -u smarty/libs/internals/core.write_file.php:1.4 smarty/libs/internals/core.write_file.php:1.5
--- smarty/libs/internals/core.write_file.php:1.4 Wed Jan 10 16:28:38 2007
+++ smarty/libs/internals/core.write_file.php Tue Feb 27 22:22:09 2007
@@ -15,10 +15,6 @@
*/
function smarty_core_write_file($params, &$smarty)
{
- static $OS;
- if (is_null($OS)) {
- $OS = substr(PHP_OS,0,3);
- }
$_dirname = dirname($params['filename']);
if ($params['create_dirs']) {
@@ -41,7 +37,7 @@
fwrite($fd, $params['contents']);
fclose($fd);
- if ($OS == 'WIN' || !@rename($_tmp_file, $params['filename'])) {
+ if (DIRECTORY_SEPARATOR == '\\' || !@rename($_tmp_file, $params['filename'])) {
// On platforms and filesystems that cannot overwrite with rename()
// delete the file before renaming it -- because windows always suffers
// this, it is short-circuited to avoid the initial rename() attempt
http://cvs.php.net/viewvc.cgi/smarty/libs/plugins/modifier.date_format.php?r1=1.18&r2=1.19&diff_format=u
Index: smarty/libs/plugins/modifier.date_format.php
diff -u smarty/libs/plugins/modifier.date_format.php:1.18 smarty/libs/plugins/modifier.date_format.php:1.19
--- smarty/libs/plugins/modifier.date_format.php:1.18 Wed Jan 10 18:55:58 2007
+++ smarty/libs/plugins/modifier.date_format.php Tue Feb 27 22:22:09 2007
@@ -8,7 +8,7 @@
/**
* Include the {@link shared.make_timestamp.php} plugin
*/
-require_once $smarty->_get_plugin_filepath('shared','make_timestamp');
+require_once $smarty->_get_plugin_filepath('shared', 'make_timestamp');
/**
* Smarty date_format modifier plugin
*
@@ -28,22 +28,29 @@
* @return string|void
* @uses smarty_make_timestamp()
*/
-function smarty_modifier_date_format($string, $format="%b %e, %Y", $default_date=null)
+function smarty_modifier_date_format($string, $format = '%b %e, %Y', $default_date = '')
{
- if (substr(PHP_OS,0,3) == 'WIN') {
- $hours = strftime('%I', smarty_make_timestamp($string));
- $short_hours = ( $hours < 10 ) ? substr( $hours, -1) : $hours;
- $_win_from = array ('%e', '%T', '%D', '%l', '%R');
- $_win_to = array ('%#d', '%H:%M:%S', '%m/%d/%y', $short_hours, '%H:%M');
- $format = str_replace($_win_from, $_win_to, $format);
- }
- if($string != '') {
- return strftime($format, smarty_make_timestamp($string));
- } elseif (isset($default_date) && $default_date != '') {
- return strftime($format, smarty_make_timestamp($default_date));
+ if ($string != '') {
+ $timestamp = smarty_make_timestamp($string);
+ } elseif ($default_date != '') {
+ $timestamp = smarty_make_timestamp($default_date);
} else {
return;
}
+ if (DIRECTORY_SEPARATOR == '\\') {
+ $_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T');
+ $_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S');
+ if (strpos($format, '%e') !== false) {
+ $_win_from[] = '%e';
+ $_win_to[] = sprintf('%\' 2d', date('j', $timestamp));
+ }
+ if (strpos($format, '%l') !== false) {
+ $_win_from[] = '%l';
+ $_win_to[] = sprintf('%\' 2d', date('h', $timestamp));
+ }
+ $format = str_replace($_win_from, $_win_to, $format);
+ }
+ return strftime($format, $timestamp);
}
/* vim: set expandtab: */