/* Advanced Interface */
PHPAPI zval *php_date_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC)
{
- Z_TYPE_P(object) = IS_OBJECT;
object_init_ex(object, pce);
- Z_SET_REFCOUNT_P(object, 1);
- Z_UNSET_ISREF_P(object);
-
return object;
}
zval *timezone_object = NULL;
char *time_str = NULL;
int time_str_len = 0;
+ zval datetime_object;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sO!", &time_str, &time_str_len, &timezone_object, date_ce_timezone) == FAILURE) {
RETURN_FALSE;
}
- php_date_instantiate(date_ce_date, return_value TSRMLS_CC);
- if (!php_date_initialize(zend_object_store_get_object(return_value TSRMLS_CC), time_str, time_str_len, NULL, timezone_object, 0 TSRMLS_CC)) {
+ php_date_instantiate(date_ce_date, &datetime_object TSRMLS_CC);
+ if (!php_date_initialize(zend_object_store_get_object(&datetime_object TSRMLS_CC), time_str, time_str_len, NULL, timezone_object, 0 TSRMLS_CC)) {
+ zval_dtor(&datetime_object);
RETURN_FALSE;
+ } else {
+ zval *datetime_object_ptr = &datetime_object;
+ RETVAL_ZVAL(datetime_object_ptr, 0, 0);
}
}
/* }}} */
zval *timezone_object = NULL;
char *time_str = NULL, *format_str = NULL;
int time_str_len = 0, format_str_len = 0;
+ zval datetime_object;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|O", &format_str, &format_str_len, &time_str, &time_str_len, &timezone_object, date_ce_timezone) == FAILURE) {
RETURN_FALSE;
}
- php_date_instantiate(date_ce_date, return_value TSRMLS_CC);
- if (!php_date_initialize(zend_object_store_get_object(return_value TSRMLS_CC), time_str, time_str_len, format_str, timezone_object, 0 TSRMLS_CC)) {
+ php_date_instantiate(date_ce_date, &datetime_object TSRMLS_CC);
+ if (!php_date_initialize(zend_object_store_get_object(&datetime_object TSRMLS_CC), time_str, time_str_len, format_str, timezone_object, 0 TSRMLS_CC)) {
+ zval_dtor(&datetime_object);
RETURN_FALSE;
+ } else {
+ zval *datetime_object_ptr = &datetime_object;
+ RETVAL_ZVAL(datetime_object_ptr, 0, 0);
}
}
/* }}} */
}
/* }}} */
-static int php_date_initialize_from_hash(zval **return_value, php_date_obj **dateobj, HashTable *myht TSRMLS_DC)
+static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht TSRMLS_DC)
{
zval **z_date = NULL;
zval **z_timezone = NULL;
php_date_instantiate(date_ce_date, return_value TSRMLS_CC);
dateobj = (php_date_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
- if (!php_date_initialize_from_hash(&return_value, &dateobj, myht TSRMLS_CC)) {
+ if (!php_date_initialize_from_hash(&dateobj, myht TSRMLS_CC)) {
php_error(E_ERROR, "Invalid serialization data for DateTime object");
}
}
myht = Z_OBJPROP_P(object);
- if (!php_date_initialize_from_hash(&return_value, &dateobj, myht TSRMLS_CC)) {
+ if (!php_date_initialize_from_hash(&dateobj, myht TSRMLS_CC)) {
php_error(E_ERROR, "Invalid serialization data for DateTime object");
}
}
string(6) "Y-m-d+"
string(19) "2001-11-29 13:20:01"
-object(DateTime)#2 (3) {
+object(DateTime)#%d (3) {
["date"]=>
string(26) "2001-11-29 %d:%d:%d.%d"
["timezone_type"]=>
string(7) "Y-m-d +"
string(19) "2001-11-29 13:20:01"
-object(DateTime)#3 (3) {
+object(DateTime)#%d (3) {
["date"]=>
string(26) "2001-11-29 %d:%d:%d.%d"
["timezone_type"]=>
string(6) "Y-m-d+"
string(10) "2001-11-29"
-object(DateTime)#2 (3) {
+object(DateTime)#%d (3) {
["date"]=>
string(26) "2001-11-29 %d:%d:%d.%d"
["timezone_type"]=>
string(7) "Y-m-d +"
string(11) "2001-11-29 "
-object(DateTime)#2 (3) {
+object(DateTime)#%d (3) {
["date"]=>
string(26) "2001-11-29 %d:%d:%d.%d"
["timezone_type"]=>