sterling Wed Sep 29 00:57:19 2004 EDT
Modified files:
/php-src configure.in
/php-src/ext/standard basic_functions.c datetime.c datetime.h
Log:
Add strptime function.
http://cvs.php.net/diff.php/php-src/configure.in?r1=1.518&r2=1.519&ty=u
Index: php-src/configure.in
diff -u php-src/configure.in:1.518 php-src/configure.in:1.519
--- php-src/configure.in:1.518 Sat Sep 25 21:10:05 2004
+++ php-src/configure.in Wed Sep 29 00:57:18 2004
@@ -1,4 +1,4 @@
-dnl ## $Id: configure.in,v 1.518 2004/09/26 01:10:05 wez Exp $ -*- sh -*-
+dnl ## $Id: configure.in,v 1.519 2004/09/29 04:57:18 sterling Exp $ -*- sh -*-
dnl ## Process this file with autoconf to produce a configure script.
divert(1)
@@ -548,6 +548,7 @@
strdup \
strerror \
strftime \
+strptime \
strstr \
strtok_r \
symlink \
http://cvs.php.net/diff.php/php-src/ext/standard/basic_functions.c?r1=1.690&r2=1.691&ty=u
Index: php-src/ext/standard/basic_functions.c
diff -u php-src/ext/standard/basic_functions.c:1.690
php-src/ext/standard/basic_functions.c:1.691
--- php-src/ext/standard/basic_functions.c:1.690 Sun Sep 26 17:55:21 2004
+++ php-src/ext/standard/basic_functions.c Wed Sep 29 00:57:18 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: basic_functions.c,v 1.690 2004/09/26 21:55:21 helly Exp $ */
+/* $Id: basic_functions.c,v 1.691 2004/09/29 04:57:18 sterling Exp $ */
#include "php.h"
#include "php_streams.h"
@@ -170,7 +170,9 @@
PHP_FE(time,
NULL)
PHP_FE(mktime,
NULL)
PHP_FE(gmmktime,
NULL)
-
+#if HAVE_STRPTIME
+ PHP_FE(strptime,
NULL)
+#endif
#if HAVE_STRFTIME
PHP_FE(strftime,
NULL)
PHP_FE(gmstrftime,
NULL)
http://cvs.php.net/diff.php/php-src/ext/standard/datetime.c?r1=1.123&r2=1.124&ty=u
Index: php-src/ext/standard/datetime.c
diff -u php-src/ext/standard/datetime.c:1.123 php-src/ext/standard/datetime.c:1.124
--- php-src/ext/standard/datetime.c:1.123 Sat Sep 25 11:26:55 2004
+++ php-src/ext/standard/datetime.c Wed Sep 29 00:57:19 2004
@@ -18,7 +18,11 @@
+----------------------------------------------------------------------+
*/
-/* $Id: datetime.c,v 1.123 2004/09/25 15:26:55 hyanantha Exp $ */
+/* $Id: datetime.c,v 1.124 2004/09/29 04:57:19 sterling Exp $ */
+
+#if HAVE_STRPTIME
+#define _XOPEN_SOURCE
+#endif
#include "php.h"
#include "zend_operators.h"
@@ -1094,6 +1098,41 @@
}
/* }}} */
+#if HAVE_STRPTIME
+/* {{{ proto string strptime(string timestamp, string format)
+ Parse a time/date generated with strftime() */
+PHP_FUNCTION(strptime)
+{
+ char *ts;
+ int ts_length;
+ char *format;
+ int format_length;
+ struct tm parsed_time;
+ char *unparsed_part;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss",
+ &ts, &ts_length, &format, &format_length) == FAILURE) {
+ return;
+ }
+
+ unparsed_part = strptime(ts, format, &parsed_time);
+ if (unparsed_part == NULL) {
+ RETURN_FALSE;
+ }
+
+ array_init(return_value);
+ add_assoc_long(return_value, "tm_sec", parsed_time.tm_sec);
+ add_assoc_long(return_value, "tm_min", parsed_time.tm_min);
+ add_assoc_long(return_value, "tm_hour", parsed_time.tm_hour);
+ add_assoc_long(return_value, "tm_mday", parsed_time.tm_mday);
+ add_assoc_long(return_value, "tm_mon", parsed_time.tm_mon);
+ add_assoc_long(return_value, "tm_year", parsed_time.tm_year);
+ add_assoc_long(return_value, "tm_wday", parsed_time.tm_wday);
+ add_assoc_long(return_value, "tm_yday", parsed_time.tm_yday);
+ add_assoc_string(return_value, "unparsed", unparsed_part, 1);
+}
+/* }}} */
+#endif
/*
* Local variables:
http://cvs.php.net/diff.php/php-src/ext/standard/datetime.h?r1=1.16&r2=1.17&ty=u
Index: php-src/ext/standard/datetime.h
diff -u php-src/ext/standard/datetime.h:1.16 php-src/ext/standard/datetime.h:1.17
--- php-src/ext/standard/datetime.h:1.16 Thu Jan 8 12:32:51 2004
+++ php-src/ext/standard/datetime.h Wed Sep 29 00:57:19 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: datetime.h,v 1.16 2004/01/08 17:32:51 sniper Exp $ */
+/* $Id: datetime.h,v 1.17 2004/09/29 04:57:19 sterling Exp $ */
#ifndef DATETIME_H
#define DATETIME_H
@@ -31,6 +31,9 @@
PHP_FUNCTION(localtime);
PHP_FUNCTION(getdate);
PHP_FUNCTION(checkdate);
+#if HAVE_STRPTIME
+PHP_FUNCTION(strptime);
+#endif
#if HAVE_STRFTIME
PHP_FUNCTION(strftime);
PHP_FUNCTION(gmstrftime);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php