summaryrefslogtreecommitdiff
path: root/ext/intl/php_intl.c
diff options
context:
space:
mode:
authorGustavo André dos Santos Lopes <cataphract@php.net>2012-04-30 15:15:09 +0200
committerGustavo André dos Santos Lopes <cataphract@php.net>2012-05-17 17:23:51 +0200
commit4cfd9995daf249c02f4d8a23f96288d1b2a2f4c0 (patch)
tree9a05442b20a264bcb2d3f8157b585c6686d911ab /ext/intl/php_intl.c
parent22f4a307481f1667bdc95f7ec7c43538427b73ab (diff)
downloadphp-git-4cfd9995daf249c02f4d8a23f96288d1b2a2f4c0.tar.gz
Added IntlTimeZone::fromDateTimeZone() and ::toDateTimeZone.
IntlTimeZone::fromDateTimeZone(DateTimeZone $dtz) converts from an ext/date TimeZone to an IntlTimeZone. The conversion is done by feeding the time zone name (essentially what would be given by DateTimeZone::getName()) to ICU's TimeZone::createTimeZone except if it's an offset time zone. In that case, the offset is read from the ext/date time zone object structure and an appopriate id (of the form GMT<+|-><HH:MM>) is given to ICU's TimeZone::createTimeZone. Not all ext/date time zones are recognized for ICU. For instance, WEST is not. Note that these kind of abbreviations, as far as I can tell, can only be created via ext/date DateTime, not directly through DateTimeZone's constructor. For IntlTimeZone::toDateTimeZone(), the behavior is symmetrical. We instantiate a DateTimeZone and then call its constructor if we don't have an offset time zone, otherwise we mess with its structure. If the timezone is not valid for ext/date, then we allow the exception of DateTimeZone constructor to propagate.
Diffstat (limited to 'ext/intl/php_intl.c')
-rwxr-xr-xext/intl/php_intl.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/ext/intl/php_intl.c b/ext/intl/php_intl.c
index 51aece69d5..4924fdef39 100755
--- a/ext/intl/php_intl.c
+++ b/ext/intl/php_intl.c
@@ -414,6 +414,10 @@ ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_idarg_static, 0, 0, 1 )
ZEND_ARG_INFO( 0, zoneId )
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_from_date_time_zone, 0, 0, 1 )
+ ZEND_ARG_OBJ_INFO( 0, dateTimeZone, IntlDateTimeZone, 0 )
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_create_enumeration, 0, 0, 0 )
ZEND_ARG_INFO( 0, countryOrRawOffset )
ZEND_END_ARG_INFO()
@@ -719,6 +723,7 @@ zend_function_entry intl_functions[] = {
/* TimeZone functions */
PHP_FE( intltz_create_time_zone, arginfo_tz_idarg_static )
+ PHP_FE( intltz_from_date_time_zone, arginfo_tz_from_date_time_zone )
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 )
@@ -742,6 +747,7 @@ zend_function_entry intl_functions[] = {
PHP_FE( intltz_has_same_rules, arginfo_tz_has_same_rules )
PHP_FE( intltz_get_display_name, arginfo_tz_get_display_name )
PHP_FE( intltz_get_dst_savings, arginfo_tz_only_tz )
+ PHP_FE( intltz_to_date_time_zone, arginfo_tz_only_tz )
PHP_FE( intltz_get_error_code, arginfo_tz_only_tz )
PHP_FE( intltz_get_error_message, arginfo_tz_only_tz )