mirror of
https://github.com/php/php-src.git
synced 2024-11-29 04:46:07 +08:00
Supported Calendar methods new to ICU 49.
This commit is contained in:
parent
7460741f99
commit
d3a29c108b
@ -351,6 +351,10 @@ ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_setLenient, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, isLenient)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_wall_time_option, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, wallTimeOption)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
/* Gregorian Calendar */
|
||||
ZEND_BEGIN_ARG_INFO_EX(ainfo_gregcal___construct, 0, 0, 0)
|
||||
ZEND_ARG_INFO(0, timeZoneOrYear)
|
||||
@ -408,6 +412,12 @@ static const zend_function_entry Calendar_class_functions[] = {
|
||||
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(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)
|
||||
PHP_ME_MAPPING(getSkippedWallTimeOption,intlcal_get_skipped_wall_time_option,ainfo_cal_void, ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(setRepeatedWallTimeOption,intlcal_set_repeated_wall_time_option,ainfo_cal_wall_time_option,ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(setSkippedWallTimeOption,intlcal_set_skipped_wall_time_option,ainfo_cal_wall_time_option,ZEND_ACC_PUBLIC)
|
||||
#endif
|
||||
PHP_ME_MAPPING(getErrorCode, intlcal_get_error_code, ainfo_cal_void, ZEND_ACC_PUBLIC)
|
||||
PHP_ME_MAPPING(getErrorMessage, intlcal_get_error_message, ainfo_cal_void, ZEND_ACC_PUBLIC)
|
||||
PHP_FE_END
|
||||
@ -505,5 +515,10 @@ void calendar_register_IntlCalendar_class(TSRMLS_D)
|
||||
CALENDAR_DECL_LONG_CONST("DOW_TYPE_WEEKEND_OFFSET", UCAL_WEEKEND_ONSET);
|
||||
CALENDAR_DECL_LONG_CONST("DOW_TYPE_WEEKEND_CEASE", UCAL_WEEKEND_CEASE);
|
||||
|
||||
#if U_ICU_VERSION_MAJOR_NUM >= 49
|
||||
CALENDAR_DECL_LONG_CONST("WALLTIME_FIRST", UCAL_WALLTIME_FIRST);
|
||||
CALENDAR_DECL_LONG_CONST("WALLTIME_LAST", UCAL_WALLTIME_LAST);
|
||||
CALENDAR_DECL_LONG_CONST("WALLTIME_NEXT_VALID", UCAL_WALLTIME_NEXT_VALID);
|
||||
#endif
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -1019,6 +1019,93 @@ U_CFUNC PHP_FUNCTION(intlcal_equals)
|
||||
RETURN_BOOL((int)result);
|
||||
}
|
||||
|
||||
#if U_ICU_VERSION_MAJOR_NUM >= 49
|
||||
|
||||
U_CFUNC PHP_FUNCTION(intlcal_get_repeated_wall_time_option)
|
||||
{
|
||||
CALENDAR_METHOD_INIT_VARS;
|
||||
|
||||
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
|
||||
"O", &object, Calendar_ce_ptr) == FAILURE) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"intlcal_get_repeated_wall_time_option: bad arguments", 0 TSRMLS_CC);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
CALENDAR_METHOD_FETCH_OBJECT;
|
||||
|
||||
RETURN_LONG(co->ucal->getRepeatedWallTimeOption());
|
||||
}
|
||||
|
||||
U_CFUNC PHP_FUNCTION(intlcal_get_skipped_wall_time_option)
|
||||
{
|
||||
CALENDAR_METHOD_INIT_VARS;
|
||||
|
||||
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
|
||||
"O", &object, Calendar_ce_ptr) == FAILURE) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"intlcal_get_skipped_wall_time_option: bad arguments", 0 TSRMLS_CC);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
CALENDAR_METHOD_FETCH_OBJECT;
|
||||
|
||||
RETURN_LONG(co->ucal->getSkippedWallTimeOption());
|
||||
}
|
||||
|
||||
U_CFUNC PHP_FUNCTION(intlcal_set_repeated_wall_time_option)
|
||||
{
|
||||
long option;
|
||||
CALENDAR_METHOD_INIT_VARS;
|
||||
|
||||
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
|
||||
"Ol", &object, Calendar_ce_ptr, &option) == FAILURE) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"intlcal_set_repeated_wall_time_option: bad arguments", 0 TSRMLS_CC);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (option != UCAL_WALLTIME_FIRST && option != UCAL_WALLTIME_LAST) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"intlcal_set_repeated_wall_time_option: invalid option", 0 TSRMLS_CC);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
CALENDAR_METHOD_FETCH_OBJECT;
|
||||
|
||||
co->ucal->setRepeatedWallTimeOption((UCalendarWallTimeOption)option);
|
||||
|
||||
RETURN_TRUE;
|
||||
}
|
||||
|
||||
U_CFUNC PHP_FUNCTION(intlcal_set_skipped_wall_time_option)
|
||||
{
|
||||
long option;
|
||||
CALENDAR_METHOD_INIT_VARS;
|
||||
|
||||
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
|
||||
"Ol", &object, Calendar_ce_ptr, &option) == FAILURE) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"intlcal_set_skipped_wall_time_option: bad arguments", 0 TSRMLS_CC);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (option != UCAL_WALLTIME_FIRST && option != UCAL_WALLTIME_LAST
|
||||
&& option != UCAL_WALLTIME_NEXT_VALID) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
"intlcal_set_skipped_wall_time_option: invalid option", 0 TSRMLS_CC);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
CALENDAR_METHOD_FETCH_OBJECT;
|
||||
|
||||
co->ucal->setSkippedWallTimeOption((UCalendarWallTimeOption)option);
|
||||
|
||||
RETURN_TRUE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
U_CFUNC PHP_FUNCTION(intlcal_get_error_code)
|
||||
{
|
||||
CALENDAR_METHOD_INIT_VARS;
|
||||
|
@ -93,6 +93,14 @@ PHP_FUNCTION(intlcal_set_lenient);
|
||||
|
||||
PHP_FUNCTION(intlcal_equals);
|
||||
|
||||
PHP_FUNCTION(intlcal_get_repeated_wall_time_option);
|
||||
|
||||
PHP_FUNCTION(intlcal_get_skipped_wall_time_option);
|
||||
|
||||
PHP_FUNCTION(intlcal_set_repeated_wall_time_option);
|
||||
|
||||
PHP_FUNCTION(intlcal_set_skipped_wall_time_option);
|
||||
|
||||
PHP_FUNCTION(intlcal_get_error_code);
|
||||
|
||||
PHP_FUNCTION(intlcal_get_error_message);
|
||||
|
@ -556,6 +556,11 @@ ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_set_lenient, 0, 0, 2 )
|
||||
ZEND_ARG_INFO( 0, isLenient )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_wall_time_option, 0, 0, 2 )
|
||||
ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 )
|
||||
ZEND_ARG_INFO( 0, wallTimeOption )
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
/* Gregorian Calendar */
|
||||
ZEND_BEGIN_ARG_INFO_EX( ainfo_gregcal_create_instance, 0, 0, 0 )
|
||||
ZEND_ARG_INFO(0, timeZoneOrYear)
|
||||
@ -765,6 +770,12 @@ zend_function_entry intl_functions[] = {
|
||||
PHP_FE( intlcal_set_first_day_of_week, ainfo_cal_dow )
|
||||
PHP_FE( intlcal_set_lenient, ainfo_cal_set_lenient )
|
||||
PHP_FE( intlcal_equals, ainfo_cal_other_cal )
|
||||
#if U_ICU_VERSION_MAJOR_NUM >= 49
|
||||
PHP_FE( intlcal_get_repeated_wall_time_option, ainfo_cal_only_cal )
|
||||
PHP_FE( intlcal_get_skipped_wall_time_option, ainfo_cal_only_cal )
|
||||
PHP_FE( intlcal_set_repeated_wall_time_option, ainfo_cal_wall_time_option )
|
||||
PHP_FE( intlcal_set_skipped_wall_time_option, ainfo_cal_wall_time_option )
|
||||
#endif
|
||||
PHP_FE( intlcal_get_error_code, ainfo_cal_only_cal )
|
||||
PHP_FE( intlcal_get_error_message, ainfo_cal_only_cal )
|
||||
|
||||
|
@ -0,0 +1,45 @@
|
||||
--TEST--
|
||||
IntlCalendar::getSkipped/RepeatedWallTimeOption(): bad arguments
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
if (version_compare(INTL_ICU_VERSION, '49') < 0)
|
||||
die('skip for ICU 49+');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
|
||||
var_dump($c->getSkippedWallTimeOption(1));
|
||||
var_dump($c->getRepeatedWallTimeOption(1));
|
||||
|
||||
var_dump(intlcal_get_skipped_wall_time_option($c, 1));
|
||||
var_dump(intlcal_get_repeated_wall_time_option($c, 1));
|
||||
|
||||
var_dump(intlcal_get_skipped_wall_time_option(1));
|
||||
|
||||
--EXPECTF--
|
||||
|
||||
Warning: IntlCalendar::getSkippedWallTimeOption() expects exactly 0 parameters, 1 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::getSkippedWallTimeOption(): intlcal_get_skipped_wall_time_option: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::getRepeatedWallTimeOption() expects exactly 0 parameters, 1 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::getRepeatedWallTimeOption(): intlcal_get_repeated_wall_time_option: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlcal_get_skipped_wall_time_option() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
|
||||
Warning: intlcal_get_skipped_wall_time_option(): intlcal_get_skipped_wall_time_option: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlcal_get_repeated_wall_time_option() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
|
||||
Warning: intlcal_get_repeated_wall_time_option(): intlcal_get_repeated_wall_time_option: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Catchable fatal error: Argument 1 passed to intlcal_get_skipped_wall_time_option() must be an instance of IntlCalendar, integer given in %s on line %d
|
@ -0,0 +1,49 @@
|
||||
--TEST--
|
||||
IntlCalendar::get/setRepeatedWallTimeOption(): basic test
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
if (version_compare(INTL_ICU_VERSION, '49') < 0)
|
||||
die('skip for ICU 49+');
|
||||
--FILE--
|
||||
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
date_default_timezone_set('Europe/Amsterdam');
|
||||
|
||||
//28 October 2012, transition from DST
|
||||
$intlcal = new IntlGregorianCalendar(2012, 9, 28, 0, 0, 0);
|
||||
var_dump($intlcal->setRepeatedWallTimeOption(IntlCalendar::WALLTIME_LAST));
|
||||
var_dump($intlcal->getRepeatedWallTimeOption());
|
||||
$intlcal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 2);
|
||||
$intlcal->set(IntlCalendar::FIELD_MINUTE, 30);
|
||||
var_dump(
|
||||
strtotime('2012-10-28 02:30:00 +0100'),
|
||||
(int)($intlcal->getTime() /1000)
|
||||
);
|
||||
|
||||
var_dump(intlcal_set_repeated_wall_time_option($intlcal, IntlCalendar::WALLTIME_FIRST));
|
||||
var_dump(intlcal_get_repeated_wall_time_option($intlcal));
|
||||
$intlcal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 2);
|
||||
$intlcal->set(IntlCalendar::FIELD_MINUTE, 30);
|
||||
var_dump(
|
||||
strtotime('2012-10-28 02:30:00 +0200'),
|
||||
(int)($intlcal->getTime() /1000)
|
||||
);
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
|
||||
bool(true)
|
||||
int(0)
|
||||
int(1351387800)
|
||||
int(1351387800)
|
||||
bool(true)
|
||||
int(1)
|
||||
int(1351384200)
|
||||
int(1351384200)
|
||||
==DONE==
|
@ -0,0 +1,67 @@
|
||||
--TEST--
|
||||
IntlCalendar::get/setSkippedWallTimeOption(): basic test
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
if (version_compare(INTL_ICU_VERSION, '49') < 0)
|
||||
die('skip for ICU 49+');
|
||||
--FILE--
|
||||
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "nl");
|
||||
|
||||
date_default_timezone_set('Europe/Amsterdam');
|
||||
|
||||
//25 March 2012, transition to DST
|
||||
$intlcal = new IntlGregorianCalendar(2012, 2, 25, 0, 0, 0);
|
||||
var_dump($intlcal->getSkippedWallTimeOption());
|
||||
$intlcal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 2);
|
||||
$intlcal->set(IntlCalendar::FIELD_MINUTE, 30);
|
||||
echo "Should be 3h30\n";
|
||||
var_dump(
|
||||
$intlcal->get(IntlCalendar::FIELD_HOUR_OF_DAY),
|
||||
$intlcal->get(IntlCalendar::FIELD_MINUTE)
|
||||
);
|
||||
|
||||
var_dump($intlcal->setSkippedWallTimeOption(IntlCalendar::WALLTIME_FIRST));
|
||||
var_dump(intlcal_get_skipped_wall_time_option($intlcal));
|
||||
$intlcal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 2);
|
||||
$intlcal->set(IntlCalendar::FIELD_MINUTE, 30);
|
||||
echo "Should be 1h30\n";
|
||||
var_dump(
|
||||
$intlcal->get(IntlCalendar::FIELD_HOUR_OF_DAY),
|
||||
$intlcal->get(IntlCalendar::FIELD_MINUTE)
|
||||
);
|
||||
|
||||
var_dump(intlcal_set_skipped_wall_time_option($intlcal, IntlCalendar::WALLTIME_NEXT_VALID));
|
||||
var_dump($intlcal->getSkippedWallTimeOption());
|
||||
$intlcal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 2);
|
||||
$intlcal->set(IntlCalendar::FIELD_MINUTE, 30);
|
||||
echo "Should be 3h00\n";
|
||||
var_dump(
|
||||
$intlcal->get(IntlCalendar::FIELD_HOUR_OF_DAY),
|
||||
$intlcal->get(IntlCalendar::FIELD_MINUTE)
|
||||
);
|
||||
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
|
||||
int(0)
|
||||
Should be 3h30
|
||||
int(3)
|
||||
int(30)
|
||||
bool(true)
|
||||
int(1)
|
||||
Should be 1h30
|
||||
int(1)
|
||||
int(30)
|
||||
bool(true)
|
||||
int(2)
|
||||
Should be 3h00
|
||||
int(3)
|
||||
int(0)
|
||||
==DONE==
|
@ -0,0 +1,80 @@
|
||||
--TEST--
|
||||
IntlCalendar::setSkipped/RepeatedWallTimeOption(): bad arguments
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl'))
|
||||
die('skip intl extension not enabled');
|
||||
if (version_compare(INTL_ICU_VERSION, '49') < 0)
|
||||
die('skip for ICU 49+');
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$c = new IntlGregorianCalendar(NULL, 'pt_PT');
|
||||
|
||||
var_dump($c->setSkippedWallTimeOption());
|
||||
var_dump($c->setRepeatedWallTimeOption());
|
||||
|
||||
var_dump($c->setSkippedWallTimeOption(1, 2));
|
||||
var_dump($c->setRepeatedWallTimeOption(1, 2));
|
||||
|
||||
var_dump($c->setSkippedWallTimeOption(array()));
|
||||
var_dump($c->setRepeatedWallTimeOption(array()));
|
||||
|
||||
var_dump($c->setSkippedWallTimeOption(3));
|
||||
var_dump($c->setRepeatedWallTimeOption(2));
|
||||
|
||||
var_dump(intlcal_set_skipped_wall_time_option($c));
|
||||
var_dump(intlcal_set_repeated_wall_time_option($c));
|
||||
|
||||
var_dump(intlcal_set_repeated_wall_time_option(1, 1));
|
||||
|
||||
--EXPECTF--
|
||||
|
||||
Warning: IntlCalendar::setSkippedWallTimeOption() expects exactly 1 parameter, 0 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::setSkippedWallTimeOption(): intlcal_set_skipped_wall_time_option: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::setRepeatedWallTimeOption() expects exactly 1 parameter, 0 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::setRepeatedWallTimeOption(): intlcal_set_repeated_wall_time_option: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::setSkippedWallTimeOption() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::setSkippedWallTimeOption(): intlcal_set_skipped_wall_time_option: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::setRepeatedWallTimeOption() expects exactly 1 parameter, 2 given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::setRepeatedWallTimeOption(): intlcal_set_repeated_wall_time_option: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::setSkippedWallTimeOption() expects parameter 1 to be long, array given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::setSkippedWallTimeOption(): intlcal_set_skipped_wall_time_option: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::setRepeatedWallTimeOption() expects parameter 1 to be long, array given in %s on line %d
|
||||
|
||||
Warning: IntlCalendar::setRepeatedWallTimeOption(): intlcal_set_repeated_wall_time_option: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::setSkippedWallTimeOption(): intlcal_set_skipped_wall_time_option: invalid option in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: IntlCalendar::setRepeatedWallTimeOption(): intlcal_set_repeated_wall_time_option: invalid option in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlcal_set_skipped_wall_time_option() expects exactly 2 parameters, 1 given in %s on line %d
|
||||
|
||||
Warning: intlcal_set_skipped_wall_time_option(): intlcal_set_skipped_wall_time_option: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: intlcal_set_repeated_wall_time_option() expects exactly 2 parameters, 1 given in %s on line %d
|
||||
|
||||
Warning: intlcal_set_repeated_wall_time_option(): intlcal_set_repeated_wall_time_option: bad arguments in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Catchable fatal error: Argument 1 passed to intlcal_set_repeated_wall_time_option() must be an instance of IntlCalendar, integer given in %s on line %d
|
Loading…
Reference in New Issue
Block a user