@@ -72,21 +72,21 @@ U_CFUNC PHP_METHOD(IntlCalendar, __construct)
7272
7373U_CFUNC PHP_FUNCTION (intlcal_create_instance)
7474{
75- zval *zv_timezone = NULL ;
75+ zend_object *timezone_object = nullptr ;
76+ zend_string *timezone_string = nullptr ;
7677 char *locale_str = NULL ;
7778 size_t locale_len = 0 ;
78- TimeZone *timeZone;
7979 UErrorCode status = U_ZERO_ERROR;
8080 intl_error_reset (NULL );
8181
8282 ZEND_PARSE_PARAMETERS_START (0 , 2 )
8383 Z_PARAM_OPTIONAL
84- Z_PARAM_ZVAL (zv_timezone )
84+ Z_PARAM_OBJ_OR_STR_OR_NULL (timezone_object, timezone_string )
8585 Z_PARAM_STRING_OR_NULL (locale_str, locale_len)
8686 ZEND_PARSE_PARAMETERS_END ();
8787
88- timeZone = timezone_process_timezone_argument (zv_timezone, NULL );
89- if (timeZone == NULL ) {
88+ TimeZone * timeZone = timezone_process_timezone_argument (timezone_object, timezone_string, nullptr );
89+ if (timeZone == nullptr ) {
9090 RETURN_NULL ();
9191 }
9292
@@ -296,26 +296,28 @@ U_CFUNC PHP_FUNCTION(intlcal_add)
296296 RETURN_TRUE;
297297}
298298
299+ /* {{{ Set formatter's timezone. */
299300U_CFUNC PHP_FUNCTION (intlcal_set_time_zone)
300301{
301- zval *zv_timezone;
302- TimeZone *timeZone;
302+ zend_object *timezone_object = nullptr ;
303+ zend_string *timezone_string = nullptr ;
304+
303305 CALENDAR_METHOD_INIT_VARS;
304306
305- if ( zend_parse_method_parameters ( ZEND_NUM_ARGS (), getThis (),
306- " Oz! " , & object, Calendar_ce_ptr, &zv_timezone) == FAILURE) {
307- RETURN_THROWS ();
308- }
307+ ZEND_PARSE_PARAMETERS_START ( 2 , 2 )
308+ Z_PARAM_OBJECT_OF_CLASS ( object, Calendar_ce_ptr)
309+ Z_PARAM_OBJ_OR_STR_OR_NULL (timezone_object, timezone_string)
310+ ZEND_PARSE_PARAMETERS_END ();
309311
310312 CALENDAR_METHOD_FETCH_OBJECT;
311313
312- if (zv_timezone == NULL ) {
314+ if (timezone_object == nullptr && timezone_string == nullptr ) {
313315 RETURN_TRUE; /* the method does nothing if passed null */
314316 }
315317
316- timeZone = timezone_process_timezone_argument (zv_timezone,
317- CALENDAR_ERROR_P (co));
318- if (timeZone == NULL ) {
318+ TimeZone * timeZone = timezone_process_timezone_argument (
319+ timezone_object, timezone_string, CALENDAR_ERROR_P (co));
320+ if (timeZone == nullptr ) {
319321 RETURN_FALSE;
320322 }
321323
@@ -324,6 +326,34 @@ U_CFUNC PHP_FUNCTION(intlcal_set_time_zone)
324326 RETURN_TRUE;
325327}
326328
329+ U_CFUNC PHP_METHOD (IntlCalendar, setTimeZone)
330+ {
331+ zend_object *timezone_object = nullptr ;
332+ zend_string *timezone_string = nullptr ;
333+
334+ CALENDAR_METHOD_INIT_VARS;
335+
336+ ZEND_PARSE_PARAMETERS_START (1 , 1 )
337+ Z_PARAM_OBJ_OR_STR_OR_NULL (timezone_object, timezone_string)
338+ ZEND_PARSE_PARAMETERS_END ();
339+
340+ object = ZEND_THIS;
341+ CALENDAR_METHOD_FETCH_OBJECT;
342+
343+ if (timezone_object == nullptr && timezone_string == nullptr ) {
344+ RETURN_TRUE; /* the method does nothing if passed null */
345+ }
346+
347+ TimeZone *timeZone = timezone_process_timezone_argument (
348+ timezone_object, timezone_string, CALENDAR_ERROR_P (co));
349+ if (timeZone == nullptr ) {
350+ RETURN_FALSE;
351+ }
352+
353+ co->ucal ->adoptTimeZone (timeZone);
354+
355+ RETURN_TRUE;
356+ }
327357
328358static void _php_intlcal_before_after (
329359 UBool (Calendar::*func)(const Calendar&, UErrorCode&) const ,
0 commit comments