static void php_timezone_to_string(php_timezone_obj *tzobj, zval *zv);
static int date_interval_compare_objects(zval *o1, zval *o2);
-static zval *date_interval_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv);
-static zval *date_interval_write_property(zval *object, zval *member, zval *value, void **cache_slot);
-static zval *date_interval_get_property_ptr_ptr(zval *object, zval *member, int type, void **cache_slot);
-static zval *date_period_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv);
-static zval *date_period_write_property(zval *object, zval *member, zval *value, void **cache_slot);
-static zval *date_period_get_property_ptr_ptr(zval *object, zval *member, int type, void **cache_slot);
+static zval *date_interval_read_property(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv);
+static zval *date_interval_write_property(zend_object *object, zend_string *member, zval *value, void **cache_slot);
+static zval *date_interval_get_property_ptr_ptr(zend_object *object, zend_string *member, int type, void **cache_slot);
+static zval *date_period_read_property(zend_object *object, zend_string *name, int type, void **cache_slot, zval *rv);
+static zval *date_period_write_property(zend_object *object, zend_string *name, zval *value, void **cache_slot);
+static zval *date_period_get_property_ptr_ptr(zend_object *object, zend_string *name, int type, void **cache_slot);
+ static int date_object_compare_timezone(zval *tz1, zval *tz2);
+
/* {{{ Module struct */
zend_module_entry date_module_entry = {
STANDARD_MODULE_HEADER_EX,
date_object_handlers_timezone.get_properties_for = date_object_get_properties_for_timezone;
date_object_handlers_timezone.get_gc = date_object_get_gc_timezone;
date_object_handlers_timezone.get_debug_info = date_object_get_debug_info_timezone;
++ date_object_handlers_timezone.compare = date_object_compare_timezone;
#define REGISTER_TIMEZONE_CLASS_CONST_STRING(const_name, value) \
zend_declare_class_constant_long(date_ce_timezone, const_name, sizeof(const_name)-1, value);
return &new_obj->std;
} /* }}} */
+ static int date_object_compare_timezone(zval *tz1, zval *tz2) /* {{{ */
+ {
+ php_timezone_obj *o1, *o2;
+
++ ZEND_COMPARE_OBJECTS_FALLBACK(tz1, tz2);
++
+ o1 = Z_PHPTIMEZONE_P(tz1);
+ o2 = Z_PHPTIMEZONE_P(tz2);
+
+ ZEND_ASSERT(o1->initialized && o2->initialized);
+
+ if (o1->type != o2->type) {
+ php_error_docref(NULL, E_WARNING, "Trying to compare different kinds of DateTimeZone objects");
+ return 1;
+ }
+
+ switch (o1->type) {
+ case TIMELIB_ZONETYPE_OFFSET:
+ return o1->tzi.utc_offset == o2->tzi.utc_offset ? 0 : 1;
+ case TIMELIB_ZONETYPE_ABBR:
+ return strcmp(o1->tzi.z.abbr, o2->tzi.z.abbr) ? 1 : 0;
+ case TIMELIB_ZONETYPE_ID:
+ return strcmp(o1->tzi.tz->name, o2->tzi.tz->name) ? 1 : 0;
+ EMPTY_SWITCH_DEFAULT_CASE();
+ }
+ } /* }}} */
+
static void php_timezone_to_string(php_timezone_obj *tzobj, zval *zv)
{
switch (tzobj->type) {