and IntlCalendar::setMinimalDaysInFirstWeek(). This one had slipped.
we had a ::getMinimalDaysInFirstWeek() but no way to change the value.
ZEND_ARG_INFO(0, isLenient)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_set_minimal_days_in_first_week, 0, 0, 1)
+ ZEND_ARG_INFO(0, numberOfDays)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_from_date_time, 0, 0, 1)
ZEND_ARG_INFO(0, dateTime)
ZEND_END_ARG_INFO()
#endif
PHP_ME_MAPPING(setFirstDayOfWeek, intlcal_set_first_day_of_week, ainfo_cal_dow, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(setLenient, intlcal_set_lenient, ainfo_cal_setLenient, ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(setMinimalDaysInFirstWeek,intlcal_set_minimal_days_in_first_week,ainfo_cal_set_minimal_days_in_first_week,ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(equals, intlcal_equals, ainfo_cal_other_cal, ZEND_ACC_PUBLIC)
#if U_ICU_VERSION_MAJOR_NUM >= 49
PHP_ME_MAPPING(getRepeatedWallTimeOption,intlcal_get_repeated_wall_time_option,ainfo_cal_void, ZEND_ACC_PUBLIC)
RETURN_TRUE;
}
+U_CFUNC PHP_FUNCTION(intlcal_set_minimal_days_in_first_week)
+{
+ long num_days;
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "Ol", &object, Calendar_ce_ptr, &num_days) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_set_minimal_days_in_first_week: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ if (num_days < 1 || num_days > 7) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_set_minimal_days_in_first_week: invalid number of days; "
+ "must be between 1 and 7", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ co->ucal->setMinimalDaysInFirstWeek((uint8_t)num_days);
+
+ RETURN_TRUE;
+}
+
U_CFUNC PHP_FUNCTION(intlcal_equals)
{
zval *other_object;
PHP_FUNCTION(intlcal_set_lenient);
+PHP_FUNCTION(intlcal_set_minimal_days_in_first_week);
+
PHP_FUNCTION(intlcal_equals);
PHP_FUNCTION(intlcal_get_repeated_wall_time_option);
ZEND_ARG_INFO( 0, isLenient )
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_set_minimal_days_in_first_week, 0, 0, 2 )
+ ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 )
+ ZEND_ARG_INFO( 0, numberOfDays )
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_from_date_time, 0, 0, 1)
ZEND_ARG_INFO(0, dateTime)
ZEND_END_ARG_INFO()
#endif
PHP_FE( intlcal_set_first_day_of_week, ainfo_cal_dow )
PHP_FE( intlcal_set_lenient, ainfo_cal_set_lenient )
+ PHP_FE( intlcal_set_minimal_days_in_first_week, ainfo_cal_set_minimal_days_in_first_week )
PHP_FE( intlcal_equals, ainfo_cal_other_cal )
PHP_FE( intlcal_from_date_time, ainfo_cal_from_date_time )
PHP_FE( intlcal_to_date_time, ainfo_cal_only_cal )
--- /dev/null
+--TEST--
+IntlCalendar::setMinimalDaysInFirstWeek() basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+$intlcal = IntlCalendar::createInstance('UTC');
+var_dump(
+ $intlcal->setMinimalDaysInFirstWeek(6),
+ $intlcal->getMinimalDaysInFirstWeek(),
+ intlcal_set_minimal_days_in_first_week($intlcal, 5),
+ $intlcal->getMinimalDaysInFirstWeek()
+);
+?>
+==DONE==
+--EXPECT--
+bool(true)
+int(6)
+bool(true)
+int(5)
+==DONE==\r
--- /dev/null
+--TEST--
+IntlCalendar::setMinimalDaysInFirstWeek(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+
+var_dump($c->setMinimalDaysInFirstWeek());
+var_dump($c->setMinimalDaysInFirstWeek(1, 2));
+var_dump($c->setMinimalDaysInFirstWeek(0));
+
+var_dump(intlcal_set_minimal_days_in_first_week($c, 0));
+var_dump(intlcal_set_minimal_days_in_first_week(1, 2));
+
+--EXPECTF--
+Warning: IntlCalendar::setMinimalDaysInFirstWeek() expects exactly 1 parameter, 0 given in %s on line %d
+
+Warning: IntlCalendar::setMinimalDaysInFirstWeek(): intlcal_set_minimal_days_in_first_week: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::setMinimalDaysInFirstWeek() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: IntlCalendar::setMinimalDaysInFirstWeek(): intlcal_set_minimal_days_in_first_week: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::setMinimalDaysInFirstWeek(): intlcal_set_minimal_days_in_first_week: invalid number of days; must be between 1 and 7 in %s on line %d
+bool(false)
+
+Warning: intlcal_set_minimal_days_in_first_week(): intlcal_set_minimal_days_in_first_week: invalid number of days; must be between 1 and 7 in %s on line %d
+bool(false)
+
+Catchable fatal error: Argument 1 passed to intlcal_set_minimal_days_in_first_week() must be an instance of IntlCalendar, integer given in %s on line %d
+