scottmac Fri Dec 14 14:28:36 2007 UTC
Modified files: (Branch: PHP_5_3)
/php-src NEWS
/php-src/ext/date php_date.c php_date.h
Log:
MFH: Add Datetime::createFromTimestamp to allow setting of a unix timestamp
without invoking the date parser.
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.965.2.56&r2=1.2027.2.547.2.965.2.57&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.965.2.56
php-src/NEWS:1.2027.2.547.2.965.2.57
--- php-src/NEWS:1.2027.2.547.2.965.2.56 Thu Dec 13 08:57:51 2007
+++ php-src/NEWS Fri Dec 14 14:28:36 2007
@@ -23,6 +23,8 @@
(Etienne Kneuss)
- Added "compact" handler for Zend MM storage. (Dmitry)
- Added "+" and "*" specifiers to zend_parse_parameters(). (Andrei)
+- Added DateTime::createFromTimestamp() to set a unix timestamp without
+ invoking the date parser. (Scott)
- Upgraded PCRE to version 7.4 (Nuno)
http://cvs.php.net/viewvc.cgi/php-src/ext/date/php_date.c?r1=1.43.2.45.2.51.2.3&r2=1.43.2.45.2.51.2.4&diff_format=u
Index: php-src/ext/date/php_date.c
diff -u php-src/ext/date/php_date.c:1.43.2.45.2.51.2.3
php-src/ext/date/php_date.c:1.43.2.45.2.51.2.4
--- php-src/ext/date/php_date.c:1.43.2.45.2.51.2.3 Fri Nov 23 00:15:24 2007
+++ php-src/ext/date/php_date.c Fri Dec 14 14:28:36 2007
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_date.c,v 1.43.2.45.2.51.2.3 2007/11/23 00:15:24 iliaa Exp $ */
+/* $Id: php_date.c,v 1.43.2.45.2.51.2.4 2007/12/14 14:28:36 scottmac Exp $ */
#include "php.h"
#include "php_streams.h"
@@ -178,6 +178,7 @@
PHP_FE(date_time_set, NULL)
PHP_FE(date_date_set, NULL)
PHP_FE(date_isodate_set, NULL)
+ PHP_FE(date_timestamp_set, NULL)
PHP_FE(timezone_open, NULL)
PHP_FE(timezone_name_get, NULL)
@@ -208,6 +209,7 @@
PHP_ME_MAPPING(setTime, date_time_set, NULL, 0)
PHP_ME_MAPPING(setDate, date_date_set, NULL, 0)
PHP_ME_MAPPING(setISODate, date_isodate_set, NULL, 0)
+ PHP_ME_MAPPING(createFromTimestamp, date_timestamp_set, NULL, 0)
{NULL, NULL, NULL}
};
@@ -2014,6 +2016,25 @@
}
/* }}} */
+/* {{{ proto void date_timestamp_set(DateTime object, long unixTimestamp)
+ Sets the date and time based on an Unix timestamp.
+*/
+PHP_FUNCTION(date_timestamp_set)
+{
+ zval *object;
+ php_date_obj *dateobj;
+ long timestamp;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
"Ol", &object, date_ce_date, ×tamp) == FAILURE) {
+ RETURN_FALSE;
+ }
+ dateobj = (php_date_obj *) zend_object_store_get_object(object
TSRMLS_CC);
+ DATE_CHECK_INITIALIZED(dateobj->time, DateTime);
+ timelib_unixtime2gmt(dateobj->time, (timelib_sll)timestamp);
+ timelib_update_ts(dateobj->time, NULL);
+}
+/* }}} */
+
static int timezone_initialize(timelib_tzinfo **tzi, /*const*/ char *tz
TSRMLS_DC)
{
char *tzid;
http://cvs.php.net/viewvc.cgi/php-src/ext/date/php_date.h?r1=1.17.2.11.2.3&r2=1.17.2.11.2.3.2.1&diff_format=u
Index: php-src/ext/date/php_date.h
diff -u php-src/ext/date/php_date.h:1.17.2.11.2.3
php-src/ext/date/php_date.h:1.17.2.11.2.3.2.1
--- php-src/ext/date/php_date.h:1.17.2.11.2.3 Mon Jan 1 09:35:48 2007
+++ php-src/ext/date/php_date.h Fri Dec 14 14:28:36 2007
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_date.h,v 1.17.2.11.2.3 2007/01/01 09:35:48 sebastian Exp $ */
+/* $Id: php_date.h,v 1.17.2.11.2.3.2.1 2007/12/14 14:28:36 scottmac Exp $ */
#ifndef PHP_DATE_H
#define PHP_DATE_H
@@ -59,6 +59,7 @@
PHP_FUNCTION(date_time_set);
PHP_FUNCTION(date_date_set);
PHP_FUNCTION(date_isodate_set);
+PHP_FUNCTION(date_timestamp_set);
PHP_METHOD(DateTimeZone, __construct);
PHP_FUNCTION(timezone_open);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php