note 53201 deleted from function.strtotime by nlopess
| From: | nlopess@php.net | Date: | Wed, 15 Jun 2005 10:40:06 +0000 |
| Subject: | note 53201 deleted from function.strtotime by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-90453@lists.php.net to get a copy of this message | ||
Note Submitter: Msquared
----
"@unixtime" patch for strtotime()
This patch allows you to use the "@unixtime" format specified in the GNU date format page
above. Among other things, this might make Smarty more useful...
This is against the 4.3.11 source tree.
Enjoy!
diff -urN php-4.3.11.orig/ext/standard/parsedate.c php-4.3.11/ext/standard/parsedate.c
--- php-4.3.11.orig/ext/standard/parsedate.c 2005-03-30 22:35:47.000000000 +0800
+++ php-4.3.11/ext/standard/parsedate.c 2005-05-25 17:32:21.000000000 +0800
@@ -2186,6 +2186,9 @@
time_t Start;
struct date_yy date;
+ // if starts with '@' then strip '@', convert to number and return
+ if ( *p == '@' ) { return (time_t)strtol(p+1,NULL,10); };
+
date.yyInput = p;
Start = now ? *now : time ((time_t *) NULL);
tmp = localtime (&Start);
diff -urN php-4.3.11.orig/ext/standard/parsedate.y php-4.3.11/ext/standard/parsedate.y
--- php-4.3.11.orig/ext/standard/parsedate.y 2004-04-09 03:21:46.000000000 +0800
+++ php-4.3.11/ext/standard/parsedate.y 2005-05-25 17:32:25.000000000 +0800
@@ -971,6 +971,9 @@
time_t Start;
struct date_yy date;
+ // if starts with '@' then strip '@', convert to number and return
+ if ( *p == '@' ) { return (time_t)strtol(p+1,NULL,10); };
+
date.yyInput = p;
Start = now ? *now : time ((time_t *) NULL);
tmp = localtime (&Start);