com php-src: Added support for new method TimeZone::getUnknown() added in ICU 49.: ext/intl/php_intl.c ext/intl/tests/timezone_ge tUnknown_basic.phpt
ext/intl/tests/timezone_getUnknown _error.phpt ext/intl/timezone/timezone_class.cpp ex t/intl/timezone/timezone_methods.cpp ext/intl/timezone/ti
mezone_methods.h
| From: | Gustavo André dos Santos Lopes | Date: | Sun, 01 Apr 2012 14:16:56 +0000 |
| Subject: | com php-src: Added support for new method TimeZone::getUnknown() added in ICU 49.: ext/intl/php_intl.c ext/intl/tests/timezone_ge tUnknown_basic.phpt ext/intl/tests/timezone_getUnknown _error.phpt ext/intl/timezone/timezone_class.cpp ex t/intl/timezone/timezone_methods.cpp ext/intl/timezone/ti mezone_methods.h |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-68629@lists.php.net to get a copy of this message | ||
Commit: 69f75bb43c7e6f2e8b4661ff48aaf68b9b9b2c5c
Author: Gustavo André dos Santos Lopes <cataphract@php.net> Sun, 1 Apr 2012
16:16:56 +0200
Parents: d3a29c108bf146440645d8b1a3b2e0f22a34ac59
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=69f75bb43c7e6f2e8b4661ff48aaf68b9b9b2c5c
Log:
Added support for new method TimeZone::getUnknown() added in ICU 49.
Changed paths:
M ext/intl/php_intl.c
A ext/intl/tests/timezone_getUnknown_basic..phpt
A ext/intl/tests/timezone_getUnknown_error.phpt
M ext/intl/timezone/timezone_class.cpp
M ext/intl/timezone/timezone_methods.cpp
M ext/intl/timezone/timezone_methods.h
Diff:
diff --git a/ext/intl/php_intl.c b/ext/intl/php_intl.c
index 9504555..bc67443 100755
--- a/ext/intl/php_intl.c
+++ b/ext/intl/php_intl.c
@@ -718,6 +718,9 @@ zend_function_entry intl_functions[] = {
PHP_FE( intltz_create_default, arginfo_tz_void )
PHP_FE( intltz_get_id, arginfo_tz_only_tz )
PHP_FE( intltz_get_gmt, arginfo_tz_void )
+#if U_ICU_VERSION_MAJOR_NUM >= 49
+ PHP_FE( intltz_get_unknown, arginfo_tz_void )
+#endif
PHP_FE( intltz_create_enumeration, arginfo_tz_create_enumeration )
PHP_FE( intltz_count_equivalent_ids, arginfo_tz_idarg_static )
PHP_FE( intltz_create_time_zone_id_enumeration, arginfo_tz_create_time_zone_id_enumeration )
diff --git a/ext/intl/tests/timezone_getUnknown_basic.phpt
b/ext/intl/tests/timezone_getUnknown_basic.phpt
new file mode 100644
index 0000000..aef1a54
--- /dev/null
+++ b/ext/intl/tests/timezone_getUnknown_basic.phpt
@@ -0,0 +1,35 @@
+--TEST--
+IntlCalendar::getUnknown(): 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");
+
+$tz = IntlTimeZone::getUnknown();
+print_r($tz);
+$tz = intltz_get_unknown();
+print_r($tz);
+?>
+==DONE==
+--EXPECT--
+IntlTimeZone Object
+(
+ [valid] => 1
+ [id] => Etc/Unknown
+ [rawOffset] => 0
+ [currentOffset] => 0
+)
+IntlTimeZone Object
+(
+ [valid] => 1
+ [id] => Etc/Unknown
+ [rawOffset] => 0
+ [currentOffset] => 0
+)
+==DONE==
\ No newline at end of file
diff --git a/ext/intl/tests/timezone_getUnknown_error.phpt
b/ext/intl/tests/timezone_getUnknown_error.phpt
new file mode 100644
index 0000000..4aec28f
--- /dev/null
+++ b/ext/intl/tests/timezone_getUnknown_error.phpt
@@ -0,0 +1,27 @@
+--TEST--
+IntlCalendar::getUnknown(): 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');
+
+IntlTimeZone::getUnknown(1);
+
+intltz_get_unknown(1);
+
+--EXPECTF--
+
+Warning: IntlTimeZone::getUnknown() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: IntlTimeZone::getUnknown(): intltz_get_unknown: bad arguments in %s on line %d
+
+Warning: intltz_get_unknown() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: intltz_get_unknown(): intltz_get_unknown: bad arguments in %s on line %d
diff --git a/ext/intl/timezone/timezone_class.cpp b/ext/intl/timezone/timezone_class.cpp
index 5b8dfd2..dcd6292 100644
--- a/ext/intl/timezone/timezone_class.cpp
+++ b/ext/intl/timezone/timezone_class.cpp
@@ -371,6 +371,9 @@ static zend_function_entry TimeZone_class_functions[] = {
PHP_ME_MAPPING(createTimeZone, intltz_create_time_zone, ainfo_tz_idarg, ZEND_ACC_PUBLIC |
ZEND_ACC_STATIC)
PHP_ME_MAPPING(createDefault, intltz_create_default, ainfo_tz_void, ZEND_ACC_PUBLIC |
ZEND_ACC_STATIC)
PHP_ME_MAPPING(getGMT, intltz_get_gmt, ainfo_tz_void, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+#if U_ICU_VERSION_MAJOR_NUM >= 49
+ PHP_ME_MAPPING(getUnknown, intltz_get_unknown, ainfo_tz_void, ZEND_ACC_PUBLIC |
ZEND_ACC_STATIC)
+#endif
PHP_ME_MAPPING(createEnumeration, intltz_create_enumeration, ainfo_tz_createEnumeration, ZEND_ACC_PUBLIC
| ZEND_ACC_STATIC)
PHP_ME_MAPPING(countEquivalentIDs, intltz_count_equivalent_ids, ainfo_tz_idarg, ZEND_ACC_PUBLIC
| ZEND_ACC_STATIC)
PHP_ME_MAPPING(createTimeZoneIDEnumeration, intltz_create_time_zone_id_enumeration,
ainfo_tz_createTimeZoneIDEnumeration, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
diff --git a/ext/intl/timezone/timezone_methods.cpp b/ext/intl/timezone/timezone_methods.cpp
index a6de82d..37b3996 100644
--- a/ext/intl/timezone/timezone_methods.cpp
+++ b/ext/intl/timezone/timezone_methods.cpp
@@ -84,6 +84,20 @@ U_CFUNC PHP_FUNCTION(intltz_get_gmt)
timezone_object_construct(TimeZone::getGMT(), return_value, 0 TSRMLS_CC);
}
+#if U_ICU_VERSION_MAJOR_NUM >= 49
+U_CFUNC PHP_FUNCTION(intltz_get_unknown)
+{
+ intl_error_reset(NULL TSRMLS_CC);
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intltz_get_unknown: bad arguments", 0 TSRMLS_CC);
+ RETURN_NULL();
+ }
+
+ timezone_object_construct(&TimeZone::getUnknown(), return_value, 0 TSRMLS_CC);
+}
+#endif
U_CFUNC PHP_FUNCTION(intltz_create_enumeration)
{
diff --git a/ext/intl/timezone/timezone_methods.h b/ext/intl/timezone/timezone_methods.h
index b168812..207caa3 100644
--- a/ext/intl/timezone/timezone_methods.h
+++ b/ext/intl/timezone/timezone_methods.h
@@ -27,6 +27,8 @@ PHP_FUNCTION(intltz_get_id);
PHP_FUNCTION(intltz_get_gmt);
+PHP_FUNCTION(intltz_get_unknown);
+
PHP_FUNCTION(intltz_create_enumeration);
PHP_FUNCTION(intltz_count_equivalent_ids);