cvs: smarty / NEWS /libs/plugins shared.make_timestamp.php
"Messju Mohr" <[email protected]>
| Newsgroups | gmane.comp.php.cvs.smarty |
|---|---|
| Message-ID | <cvsmessju1122497665@cvsserver> |
messju Wed Jul 27 16:54:25 2005 EDT
Modified files:
/smarty/libs/plugins shared.make_timestamp.php
/smarty NEWS
Log:
removed ambiguity for numeric values passed to smarty_make_timestamp().
numeric values are *always* treated as timestamps now.
http://cvs.php.net/diff.php/smarty/libs/plugins/shared.make_timestamp.php?r1=1.7&r2=1.8&ty=u
Index: smarty/libs/plugins/shared.make_timestamp.php
diff -u smarty/libs/plugins/shared.make_timestamp.php:1.7 smarty/libs/plugins/shared.make_timestamp.php:1.8
--- smarty/libs/plugins/shared.make_timestamp.php:1.7 Fri Apr 16 04:00:51 2004
+++ smarty/libs/plugins/shared.make_timestamp.php Wed Jul 27 16:54:24 2005
@@ -16,26 +16,28 @@
function smarty_make_timestamp($string)
{
if(empty($string)) {
- $string = "now";
- }
- $time = strtotime($string);
- if (is_numeric($time) && $time != -1)
- return $time;
-
- // is mysql timestamp format of YYYYMMDDHHMMSS?
- if (preg_match('/^\d{14}$/', $string)) {
- $time = mktime(substr($string,8,2),substr($string,10,2),substr($string,12,2),
- substr($string,4,2),substr($string,6,2),substr($string,0,4));
+ // use "now":
+ $time = time();
- return $time;
+ } elseif (preg_match('/^\d{14}$/', $string)) {
+ // it is mysql timestamp format of YYYYMMDDHHMMSS?
+ $time = mktime(substr($string, 8, 2),substr($string, 10, 2),substr($string, 12, 2),
+ substr($string, 4, 2),substr($string, 6, 2),substr($string, 0, 4));
+
+ } elseif (is_numeric($string)) {
+ // it is a numeric string, we handle it as timestamp
+ $time = (int)$string;
+
+ } else {
+ // strtotime should handle it
+ $time = strtotime($string);
+ if ($time == -1 || $time === false) {
+ // strtotime() was not able to parse $string, use "now":
+ $time = time();
+ }
}
+ return $time;
- // couldn't recognize it, try to return a time
- $time = (int) $string;
- if ($time > 0)
- return $time;
- else
- return time();
}
/* vim: set expandtab: */
http://cvs.php.net/diff.php/smarty/NEWS?r1=1.505&r2=1.506&ty=u
Index: smarty/NEWS
diff -u smarty/NEWS:1.505 smarty/NEWS:1.506
--- smarty/NEWS:1.505 Fri Jul 8 09:38:39 2005
+++ smarty/NEWS Wed Jul 27 16:54:24 2005
@@ -1,3 +1,6 @@
+ - remove ambiguity for numeric values passed to smarty_make_timestamp()
+ (and thus the date_format modifier). numeric values are treated as
+ timestamps now. (andreas, messju)
- add passthru attribute feature to html_select_date (Sedgar,
monte)
- add "middle" parameter to truncate (monte)
--
Smarty CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php