cvs: php-src / NEWS /ext/standard microtime.c
| From: | Ilia Alshanetsky | Date: | Thu, 21 Oct 2004 21:20:52 +0000 |
| Subject: | cvs: php-src / NEWS /ext/standard microtime.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-29004@lists.php.net to get a copy of this message | ||
iliaa Thu Oct 21 17:20:52 2004 EDT
Modified files:
/php-src NEWS
/php-src/ext/standard microtime.c
Log:
Allow gettimeofday() return a float if optional argument is specified.
http://cvs.php.net/diff.php/php-src/NEWS?r1=1.1821&r2=1.1822&ty=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.1821 php-src/NEWS:1.1822
--- php-src/NEWS:1.1821 Thu Oct 14 19:19:35 2004
+++ php-src/NEWS Thu Oct 21 17:20:52 2004
@@ -1,6 +1,7 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2004, PHP 5.1.0
+- Allow gettimeofday() return a float if optional argument is specified. (Ilia)
- Added sqlite_fetch_column_types() 3rd argument for arrays. (Ilia)
- Added optional offset parameter to stream_get_contents() and
file_get_contents(). (Ilia)
http://cvs.php.net/diff.php/php-src/ext/standard/microtime.c?r1=1.45&r2=1.46&ty=u
Index: php-src/ext/standard/microtime.c
diff -u php-src/ext/standard/microtime.c:1.45 php-src/ext/standard/microtime.c:1.46
--- php-src/ext/standard/microtime.c:1.45 Sat Sep 25 10:54:41 2004
+++ php-src/ext/standard/microtime.c Thu Oct 21 17:20:52 2004
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: microtime.c,v 1.45 2004/09/25 14:54:41 hyanantha Exp $ */
+/* $Id: microtime.c,v 1.46 2004/10/21 21:20:52 iliaa Exp $ */
#include "php.h"
@@ -88,12 +88,22 @@
#ifdef HAVE_GETTIMEOFDAY
PHP_FUNCTION(gettimeofday)
{
+ zend_bool get_as_float = 0;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &get_as_float) ==
FAILURE) {
+ return;
+ }
+
struct timeval tp;
struct timezone tz;
memset(&tp, 0, sizeof(tp));
memset(&tz, 0, sizeof(tz));
if(gettimeofday(&tp, &tz) == 0) {
+ if (get_as_float) {
+ RETURN_DOUBLE((double)(tp.tv_sec + tp.tv_usec / MICRO_IN_SEC));
+ }
+
array_init(return_value);
add_assoc_long(return_value, "sec", tp.tv_sec);
add_assoc_long(return_value, "usec", tp.tv_usec);