]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-5.4' into PHP-5.5
authorDerick Rethans <github@derickrethans.nl>
Sun, 26 Jan 2014 13:02:37 +0000 (14:02 +0100)
committerDerick Rethans <github@derickrethans.nl>
Sun, 26 Jan 2014 13:02:37 +0000 (14:02 +0100)
1  2 
ext/date/lib/timelib.h
ext/date/php_date.c
ext/date/php_date.h

Simple merge
index c069e0ccaefaf0aa74c1a3fdf874d1423c6f0a30,c0566334db4895498b55b1cd39e98241b1da64be..0e21baffa61120a41a7a16fe51073eef8e223c2d
@@@ -3284,27 -2989,22 +3284,34 @@@ static void php_date_timezone_set(zval 
        dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC);
        DATE_CHECK_INITIALIZED(dateobj->time, DateTime);
        tzobj = (php_timezone_obj *) zend_object_store_get_object(timezone_object TSRMLS_CC);
-       if (tzobj->type != TIMELIB_ZONETYPE_ID) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can only do this for zones with ID for now");
-               return;
+       switch (tzobj->type) {
+               case TIMELIB_ZONETYPE_OFFSET:
+                       timelib_set_timezone_from_offset(dateobj->time, tzobj->tzi.utc_offset);
+                       break;
+               case TIMELIB_ZONETYPE_ABBR:
+                       timelib_set_timezone_from_abbr(dateobj->time, tzobj->tzi.z);
+                       break;
+               case TIMELIB_ZONETYPE_ID:
+                       timelib_set_timezone(dateobj->time, tzobj->tzi.tz);
+                       break;
        }
-       timelib_set_timezone(dateobj->time, tzobj->tzi.tz);
        timelib_unixtime2local(dateobj->time, dateobj->time->sse);
 +}
 +
 +/* {{{ proto DateTime date_timezone_set(DateTime object, DateTimeZone object)
 +   Sets the timezone for the DateTime object.
 +*/
 +PHP_FUNCTION(date_timezone_set)
 +{
 +      zval *object;
 +      zval *timezone_object;
 +
 +      if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &object, date_ce_date, &timezone_object, date_ce_timezone) == FAILURE) {
 +              RETURN_FALSE;
 +      }
 +
 +      php_date_timezone_set(object, timezone_object, return_value TSRMLS_CC);
  
        RETURN_ZVAL(object, 1, 0);
  }
index d4204ebd79b7a6c256b4a1d5997feface8ad589d,4ce730bb2ba4421018321ac4db3345aa7e104296..d7343e02bcb539680d12f9e09a2128c239027fdf
@@@ -137,16 -122,10 +137,11 @@@ struct _php_timezone_obj 
        int             initialized;
        int             type;
        union {
-               timelib_tzinfo *tz; /* TIMELIB_ZONETYPE_ID; */
-               timelib_sll     utc_offset; /* TIMELIB_ZONETYPE_OFFSET */
-               struct                      /* TIMELIB_ZONETYPE_ABBR */
-               {
-                       timelib_sll  utc_offset;
-                       char        *abbr;
-                       int          dst;
-               } z;
+               timelib_tzinfo   *tz;         /* TIMELIB_ZONETYPE_ID */
+               timelib_sll       utc_offset; /* TIMELIB_ZONETYPE_OFFSET */
+               timelib_abbr_info z;          /* TIMELIB_ZONETYPE_ABBR */
        } tzi;
 +      HashTable *props;
  };
  
  struct _php_interval_obj {