stas Thu Jul 10 21:58:02 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/intl php_intl.c /php-src/ext/intl/dateformat dateformat_class.c dateformat_parse.c /php-src/ext/intl/tests dateformat_localtime.phpt dateformat_parse.phpt ut_common.inc Log: fix date formatter positions (bug #14263)
http://cvs.php.net/viewvc.cgi/php-src/ext/intl/php_intl.c?r1=1.1.2.1&r2=1.1.2.2&diff_format=u Index: php-src/ext/intl/php_intl.c diff -u php-src/ext/intl/php_intl.c:1.1.2.1 php-src/ext/intl/php_intl.c:1.1.2.2 --- php-src/ext/intl/php_intl.c:1.1.2.1 Mon Jul 7 22:51:02 2008 +++ php-src/ext/intl/php_intl.c Thu Jul 10 21:58:02 2008 @@ -210,6 +210,12 @@ ZEND_ARG_INFO( 1, arg5 ) /* 1 = pass by reference */ ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX( datefmt_parse_args, 0, 0, 2 ) + ZEND_ARG_INFO( 0, formatter ) + ZEND_ARG_INFO( 0, string ) + ZEND_ARG_INFO( 1, position ) +ZEND_END_ARG_INFO() + /* }}} */ /* {{{ intl_functions @@ -299,8 +305,8 @@ PHP_FE( datefmt_is_lenient, NULL ) PHP_FE( datefmt_set_lenient, NULL ) PHP_FE( datefmt_format, NULL ) - PHP_FE( datefmt_parse, NULL ) - PHP_FE( datefmt_localtime , NULL ) + PHP_FE( datefmt_parse, datefmt_parse_args ) + PHP_FE( datefmt_localtime , datefmt_parse_args ) PHP_FE( datefmt_get_error_code, NULL ) PHP_FE( datefmt_get_error_message, NULL ) http://cvs.php.net/viewvc.cgi/php-src/ext/intl/dateformat/dateformat_class.c?r1=1.1.2.1&r2=1.1.2.2&diff_format=u Index: php-src/ext/intl/dateformat/dateformat_class.c diff -u php-src/ext/intl/dateformat/dateformat_class.c:1.1.2.1 php-src/ext/intl/dateformat/dateformat_class.c:1.1.2.2 --- php-src/ext/intl/dateformat/dateformat_class.c:1.1.2.1 Mon Jul 7 23:10:15 2008 +++ php-src/ext/intl/dateformat/dateformat_class.c Thu Jul 10 21:58:02 2008 @@ -86,6 +86,10 @@ /* {{{ IntlDateFormatter_class_functions * Every 'IntlDateFormatter' class method has an entry in this table */ +static ZEND_BEGIN_ARG_INFO_EX( datefmt_parse_args, 0, 0, 1 ) + ZEND_ARG_INFO( 0, string ) + ZEND_ARG_INFO( 1, position ) +ZEND_END_ARG_INFO() static function_entry IntlDateFormatter_class_functions[] = { PHP_ME( IntlDateFormatter, __construct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR ) @@ -102,8 +106,8 @@ PHP_NAMED_FE( setLenient, ZEND_FN( datefmt_set_lenient ), NULL ) PHP_NAMED_FE( isLenient, ZEND_FN( datefmt_is_lenient ), NULL ) PHP_NAMED_FE( format, ZEND_FN( datefmt_format ), NULL ) - PHP_NAMED_FE( parse, ZEND_FN( datefmt_parse), NULL ) - PHP_NAMED_FE( localtime, ZEND_FN( datefmt_localtime ), NULL ) + PHP_NAMED_FE( parse, ZEND_FN( datefmt_parse), datefmt_parse_args ) + PHP_NAMED_FE( localtime, ZEND_FN( datefmt_localtime ), datefmt_parse_args ) PHP_NAMED_FE( getErrorCode, ZEND_FN( datefmt_get_error_code ), NULL ) PHP_NAMED_FE( getErrorMessage, ZEND_FN( datefmt_get_error_message ), NULL ) { NULL, NULL, NULL } http://cvs.php.net/viewvc.cgi/php-src/ext/intl/dateformat/dateformat_parse.c?r1=1.1.2.1&r2=1.1.2.2&diff_format=u Index: php-src/ext/intl/dateformat/dateformat_parse.c diff -u php-src/ext/intl/dateformat/dateformat_parse.c:1.1.2.1 php-src/ext/intl/dateformat/dateformat_parse.c:1.1.2.2 --- php-src/ext/intl/dateformat/dateformat_parse.c:1.1.2.1 Mon Jul 7 23:10:15 2008 +++ php-src/ext/intl/dateformat/dateformat_parse.c Thu Jul 10 21:58:02 2008 @@ -33,7 +33,7 @@ * if set to 1 - store any error encountered in the parameter parse_error * if set to 0 - no need to store any error encountered in the parameter parse_error */ -static void internal_parse_to_timestamp(IntlDateFormatter_object *mfo, char* text_to_parse , int32_t text_len, int parse_pos , zval *return_value TSRMLS_DC){ +static void internal_parse_to_timestamp(IntlDateFormatter_object *mfo, char* text_to_parse , int32_t text_len, int32_t *parse_pos , zval *return_value TSRMLS_DC){ long result = 0; UDate timestamp =0; UChar* text_utf16 = NULL; @@ -43,7 +43,7 @@ intl_convert_utf8_to_utf16(&text_utf16 , &text_utf16_len , text_to_parse , text_len, &INTL_DATA_ERROR_CODE(mfo)); INTL_METHOD_CHECK_STATUS(mfo, "Error converting timezone to UTF-16" ); - timestamp = udat_parse( DATE_FORMAT_OBJECT(mfo), text_utf16 , text_utf16_len , &parse_pos , &INTL_DATA_ERROR_CODE(mfo)); + timestamp = udat_parse( DATE_FORMAT_OBJECT(mfo), text_utf16 , text_utf16_len , parse_pos , &INTL_DATA_ERROR_CODE(mfo)); if( text_utf16 ){ efree(text_utf16); } @@ -78,7 +78,7 @@ /* {{{ * Internal function which calls the udat_parseCalendar */ -static void internal_parse_to_localtime(IntlDateFormatter_object *mfo, char* text_to_parse , int32_t text_len, int parse_pos , zval *return_value TSRMLS_DC){ +static void internal_parse_to_localtime(IntlDateFormatter_object *mfo, char* text_to_parse , int32_t text_len, int32_t *parse_pos , zval *return_value TSRMLS_DC){ UCalendar* parsed_calendar = NULL ; UChar* text_utf16 = NULL; int32_t text_utf16_len = 0; @@ -89,7 +89,7 @@ INTL_METHOD_CHECK_STATUS(mfo, "Error converting timezone to UTF-16" ); parsed_calendar = ucal_open(NULL, -1, NULL, UCAL_GREGORIAN, &INTL_DATA_ERROR_CODE(mfo)); - udat_parseCalendar( DATE_FORMAT_OBJECT(mfo), parsed_calendar , text_utf16 , text_utf16_len , &parse_pos , &INTL_DATA_ERROR_CODE(mfo)); + udat_parseCalendar( DATE_FORMAT_OBJECT(mfo), parsed_calendar , text_utf16 , text_utf16_len , parse_pos , &INTL_DATA_ERROR_CODE(mfo)); if( text_utf16 ){ efree(text_utf16); } @@ -116,66 +116,84 @@ /* }}} */ -/* {{{ proto integer IntlDateFormatter::parse( string $text_to_parse , int $parse_pos ) +/* {{{ proto integer IntlDateFormatter::parse( string $text_to_parse [, int $parse_pos] ) * Parse the string $value starting at parse_pos to a Unix timestamp -int }}}*/ -/* {{{ proto integer datefmt_parse( IntlDateFormatter $fmt, string $text_to_parse , int $parse_pos ) +/* {{{ proto integer datefmt_parse( IntlDateFormatter $fmt, string $text_to_parse [, int $parse_pos] ) * Parse the string $value starting at parse_pos to a Unix timestamp -int }}}*/ PHP_FUNCTION(datefmt_parse) { char* text_to_parse = NULL; int32_t text_len =0; - long parse_pos =0; + zval* z_parse_pos = NULL; + int32_t parse_pos = -1; DATE_FORMAT_METHOD_INIT_VARS; // Parse parameters. - if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|l", - &object, IntlDateFormatter_ce_ptr, &text_to_parse , &text_len , &parse_pos ) == FAILURE ){ + if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|z!", + &object, IntlDateFormatter_ce_ptr, &text_to_parse , &text_len , &z_parse_pos ) == FAILURE ){ intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_parse: unable to parse input params", 0 TSRMLS_CC ); RETURN_FALSE; } - // Fetch the object. - DATE_FORMAT_METHOD_FETCH_OBJECT; - - internal_parse_to_timestamp( mfo, text_to_parse , text_len , - parse_pos , - return_value TSRMLS_CC); + // Fetch the object. + DATE_FORMAT_METHOD_FETCH_OBJECT; + if(z_parse_pos) { + convert_to_long(z_parse_pos); + parse_pos = (int32_t)Z_LVAL_P(z_parse_pos); + if(parse_pos > text_len) { + RETURN_FALSE; + } + } + internal_parse_to_timestamp( mfo, text_to_parse, text_len, z_parse_pos?&parse_pos:NULL, return_value TSRMLS_CC); + if(z_parse_pos) { + zval_dtor(z_parse_pos); + ZVAL_LONG(z_parse_pos, parse_pos); + } } /* }}} */ -/* {{{ proto integer IntlDateFormatter::localtime( string $text_to_parse, int $parse_pos ) +/* {{{ proto integer IntlDateFormatter::localtime( string $text_to_parse[, int $parse_pos] ) * Parse the string $value to a localtime array }}}*/ -/* {{{ proto integer datefmt_localtime( IntlDateFormatter $fmt, string $text_to_parse, int $parse_pos ) +/* {{{ proto integer datefmt_localtime( IntlDateFormatter $fmt, string $text_to_parse[, int $parse_pos ]) * Parse the string $value to a localtime array }}}*/ PHP_FUNCTION(datefmt_localtime) { char* text_to_parse = NULL; int32_t text_len =0; - long parse_pos =0; + zval* z_parse_pos = NULL; + int32_t parse_pos = -1; DATE_FORMAT_METHOD_INIT_VARS; // Parse parameters. - if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Osl", - &object, IntlDateFormatter_ce_ptr, &text_to_parse , &text_len , &parse_pos ) == FAILURE ){ + if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|z!", + &object, IntlDateFormatter_ce_ptr, &text_to_parse , &text_len , &z_parse_pos ) == FAILURE ){ intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_parse_to_localtime: unable to parse input params", 0 TSRMLS_CC ); RETURN_FALSE; } - // Fetch the object. - DATE_FORMAT_METHOD_FETCH_OBJECT; - - internal_parse_to_localtime( mfo, text_to_parse , text_len , - parse_pos, - return_value TSRMLS_CC); + // Fetch the object. + DATE_FORMAT_METHOD_FETCH_OBJECT; + if(z_parse_pos) { + convert_to_long(z_parse_pos); + parse_pos = (int32_t)Z_LVAL_P(z_parse_pos); + if(parse_pos > text_len) { + RETURN_FALSE; + } + } + internal_parse_to_localtime( mfo, text_to_parse , text_len , z_parse_pos?&parse_pos:NULL, return_value TSRMLS_CC); + if(z_parse_pos) { + zval_dtor(z_parse_pos); + ZVAL_LONG(z_parse_pos, parse_pos); + } } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/intl/tests/dateformat_localtime.phpt?r1=1.1.2.1&r2=1.1.2.2&diff_format=u Index: php-src/ext/intl/tests/dateformat_localtime.phpt diff -u php-src/ext/intl/tests/dateformat_localtime.phpt:1.1.2.1 php-src/ext/intl/tests/dateformat_localtime.phpt:1.1.2.2 --- php-src/ext/intl/tests/dateformat_localtime.phpt:1.1.2.1 Mon Jul 7 22:51:04 2008 +++ php-src/ext/intl/tests/dateformat_localtime.phpt Thu Jul 10 21:58:02 2008 @@ -59,11 +59,11 @@ $res_str .= "\nInput text is : $text_entry"; $cnt =0; - $parse_pos = 0; foreach( $fmt_array as $fmt_entry ){ $res_str .= "\n------------"; $res_str .= "\nIntlDateFormatter : ".$fmt_desc_array[$cnt]; + $parse_pos = 0; $cnt++; $parsed_arr = ut_datefmt_localtime( $fmt_entry , $text_entry , $parse_pos ); http://cvs.php.net/viewvc.cgi/php-src/ext/intl/tests/dateformat_parse.phpt?r1=1.1.2.1&r2=1.1.2.2&diff_format=u Index: php-src/ext/intl/tests/dateformat_parse.phpt diff -u php-src/ext/intl/tests/dateformat_parse.phpt:1.1.2.1 php-src/ext/intl/tests/dateformat_parse.phpt:1.1.2.2 --- php-src/ext/intl/tests/dateformat_parse.phpt:1.1.2.1 Mon Jul 7 22:51:04 2008 +++ php-src/ext/intl/tests/dateformat_parse.phpt Thu Jul 10 21:58:02 2008 @@ -38,13 +38,16 @@ ); $parse_pos = 0; - foreach( $text_arr as $text_entry){ - for ( $parse_pos = 0 ; $parse_pos < strlen($text_entry) ; $parse_pos++ ){ $fmt = ut_datefmt_create( 'en_US_CA', IntlDateFormatter::NONE, IntlDateFormatter::SHORT); + foreach( $text_arr as $text_entry){ + for ( $parse_pos = 0 ; $parse_pos< strlen($text_entry) ; $parse_pos++ ){ + $i = $parse_pos; $parsed = ut_datefmt_parse( $fmt , $text_entry , $parse_pos ); if( intl_get_error_code() == U_ZERO_ERROR){ $res_str .= "\nInput text :$text_entry ; Parsed text : $parsed"; - $res_str .= " ; parse_pos : $parse_pos"; + $res_str .= " ; parse_pos : $i $parse_pos"; + } else { + $parse_pos = $i; } /* else{ @@ -65,18 +68,10 @@ ut_run(); ?> --EXPECT-- -Input text :Sunday, September 18, 2039 4:06:40 PM PT ; Parsed text : 96000 ; parse_pos : 29 -Input text :Sunday, September 18, 2039 4:06:40 PM PT ; Parsed text : 96000 ; parse_pos : 30 -Input text :Wednesday, December 17, 1969 6:40:00 PM PT ; Parsed text : 216000 ; parse_pos : 31 -Input text :Wednesday, December 17, 1969 6:40:00 PM PT ; Parsed text : 72000 ; parse_pos : 32 -Input text :Thursday, December 18, 1969 8:49:59 AM PST ; Parsed text : 208740 ; parse_pos : 30 -Input text :Thursday, December 18, 1969 8:49:59 AM PST ; Parsed text : 64740 ; parse_pos : 31 -Input text :Thursday, December 18, 1969 8:49:59 PM PST ; Parsed text : 251940 ; parse_pos : 30 -Input text :Thursday, December 18, 1969 8:49:59 PM PST ; Parsed text : 107940 ; parse_pos : 31 -Input text :December 18, 1969 8:49:59 AM PST ; Parsed text : 208740 ; parse_pos : 20 -Input text :December 18, 1969 8:49:59 AM PST ; Parsed text : 64740 ; parse_pos : 21 -Input text :12/18/69 8:49 AM ; Parsed text : 60540 ; parse_pos : 8 -Input text :12/18/69 8:49 AM ; Parsed text : 60540 ; parse_pos : 9 -Input text :19691218 08:49 AM ; Parsed text : 60540 ; parse_pos : 8 -Input text :19691218 08:49 AM ; Parsed text : 60540 ; parse_pos : 9 -Input text :19691218 08:49 AM ; Parsed text : 60540 ; parse_pos : 10 +Input text :Sunday, September 18, 2039 4:06:40 PM PT ; Parsed text : 96000 ; parse_pos : 29 37 +Input text :Wednesday, December 17, 1969 6:40:00 PM PT ; Parsed text : 216000 ; parse_pos : 31 39 +Input text :Thursday, December 18, 1969 8:49:59 AM PST ; Parsed text : 208740 ; parse_pos : 30 38 +Input text :Thursday, December 18, 1969 8:49:59 PM PST ; Parsed text : 251940 ; parse_pos : 30 38 +Input text :December 18, 1969 8:49:59 AM PST ; Parsed text : 208740 ; parse_pos : 20 28 +Input text :12/18/69 8:49 AM ; Parsed text : 60540 ; parse_pos : 8 16 +Input text :19691218 08:49 AM ; Parsed text : 60540 ; parse_pos : 8 17 http://cvs.php.net/viewvc.cgi/php-src/ext/intl/tests/ut_common.inc?r1=1.1.2.1&r2=1.1.2.2&diff_format=u Index: php-src/ext/intl/tests/ut_common.inc diff -u php-src/ext/intl/tests/ut_common.inc:1.1.2.1 php-src/ext/intl/tests/ut_common.inc:1.1.2.2 --- php-src/ext/intl/tests/ut_common.inc:1.1.2.1 Mon Jul 7 22:51:04 2008 +++ php-src/ext/intl/tests/ut_common.inc Thu Jul 10 21:58:02 2008 @@ -1,385 +1,385 @@ -<?php -/* - * Run unit test in OO- and in procedural mode. - * Then compare the outputs. - * It they're equal then show one of them. - * Otherwise indicate an error. - */ -function ut_run() -{ - // Run unit test in OO mode. - $GLOBALS['oo-mode'] = true; - $oo_result = ut_main(); - - // Run unit test in procedural mode. - $GLOBALS['oo-mode'] = false; - $proc_result = ut_main(); - - // Show error if the APIs produce different results. - if( $proc_result !== $oo_result ) - { - echo "ERROR: OO- and procedural APIs produce different results!\n"; - echo "OO API output:\n"; - echo str_repeat( '=', 78 ) . "\n"; - echo $oo_result; - echo str_repeat( '=', 78 ) . "\n"; - echo "procedural API output:\n"; - echo str_repeat( '=', 78 ) . "\n"; - echo $proc_result; - echo str_repeat( '=', 78 ) . "\n"; - return; - } - - // Else, if the results are equal, show one of them. - echo $proc_result; -} - -function dump( $val ) -{ - return var_export( $val, true ); -} - -/* - * Wrappers around Collator methods to run them in either OO- or procedural mode. - */ - -function ut_coll_create( $locale ) -{ - return $GLOBALS['oo-mode'] ? Collator::create( $locale ) : collator_create( $locale ); -} -function ut_coll_compare( $coll, $str1, $str2 ) -{ - return $GLOBALS['oo-mode'] ? $coll->compare( $str1, $str2 ) : collator_compare( $coll, $str1, $str2 ); -} -function ut_coll_sort( $coll, &$arr, $sort_flag = Collator::SORT_REGULAR ) -{ - return $GLOBALS['oo-mode'] ? $coll->sort( $arr, $sort_flag ) : collator_sort( $coll, $arr, $sort_flag ); -} -function ut_coll_sort_with_sort_keys( $coll, &$arr ) -{ - return $GLOBALS['oo-mode'] ? $coll->sortWithSortKeys( $arr ) : collator_sort_with_sort_keys( $coll, $arr ); -} -function ut_coll_asort( $coll, &$arr, $sort_flag = Collator::SORT_REGULAR ) -{ - return $GLOBALS['oo-mode'] ? $coll->asort( $arr, $sort_flag ) : collator_asort( $coll, $arr, $sort_flag ); -} -function ut_coll_get_locale( $coll, $type ) -{ - return $GLOBALS['oo-mode'] ? $coll->getLocale( $type ) : collator_get_locale( $coll, $type ); -} -function ut_coll_get_display_name( $obj_loc, $disp_loc ) -{ - return $GLOBALS['oo-mode'] ? Collator::getDisplayName( $obj_loc, $disp_loc ) : collator_get_display_name( $obj_loc, $disp_loc ); -} -function ut_coll_get_available_locales() -{ - return $GLOBALS['oo-mode'] ? Collator::getAvailableLocales() : collator_get_available_locales(); -} -function ut_coll_get_attribute( $coll, $attr ) -{ - return $GLOBALS['oo-mode'] ? $coll->getAttribute( $attr ) : collator_get_attribute( $coll, $attr ); -} -function ut_coll_get_strength( $coll ) -{ - return $GLOBALS['oo-mode'] ? $coll->getStrength() : collator_get_strength( $coll ); -} -function ut_coll_set_strength( $coll, $strength ) -{ - return $GLOBALS['oo-mode'] ? $coll->setStrength( $strength ) : collator_set_strength( $coll, $strength ); -} -function ut_coll_set_attribute( $coll, $attr, $val ) -{ - return $GLOBALS['oo-mode'] ? $coll->setAttribute( $attr, $val ) : collator_set_attribute( $coll, $attr, $val ); -} -function ut_coll_get_variable_top( $coll ) -{ - return $GLOBALS['oo-mode'] ? $coll->getVariableTop() : collator_get_variable_top( $coll ); -} -function ut_coll_set_variable_top( $coll, $var_top ) -{ - return $GLOBALS['oo-mode'] ? $coll->setVariableTop( $var_top ) : collator_set_variable_top( $coll, $var_top ); -} -function ut_coll_restore_variable_top( $coll, $var_top ) -{ - return $GLOBALS['oo-mode'] ? $coll->restoreVariableTop( $var_top ) : collator_restore_variable_top( $coll, $var_top ); -} -function ut_coll_get_error_code( $coll ) -{ - return $GLOBALS['oo-mode'] ? $coll->getErrorCode() : collator_get_error_code( $coll ); -} -function ut_coll_get_error_message( $coll ) -{ - return $GLOBALS['oo-mode'] ? $coll->getErrorMessage() : collator_get_error_message( $coll ); -} -function ut_coll_get_default() -{ - return $GLOBALS['oo-mode'] ? Collator::getDefault() : collator_get_default(); -} -function ut_coll_set_default( $coll ) -{ - return $GLOBALS['oo-mode'] ? Collator::setDefault( $coll ) : collator_set_default( $coll ); -} - -/* - * Wrappers around NumberFormatter methods to run them in either OO- or procedural mode. - */ - -// FIXME: incomplete list - -function ut_nfmt_create( $locale, $style, $pattern = null ) -{ - return $GLOBALS['oo-mode'] ? new NumberFormatter( $locale, $style, $pattern ) : numfmt_create( $locale, $style, $pattern ); -} -function ut_nfmt_format( $fmt, $number, $type = null ) -{ - return $GLOBALS['oo-mode'] ? $fmt->format( $number, $type ) : numfmt_format( $fmt, $number, $type ); -} -function ut_nfmt_parse( $fmt, $string, $type = NumberFormatter::TYPE_DOUBLE, &$position = null ) -{ - if(is_null($position)) { - return $GLOBALS['oo-mode'] ? $fmt->parse( $string, $type ) : numfmt_parse( $fmt, $string, $type ); - } else { - return $GLOBALS['oo-mode'] ? $fmt->parse( $string, $type, $position ) : numfmt_parse( $fmt, $string, $type, $position ); - } -} -function ut_nfmt_format_currency( $fmt, $number, $currency ) -{ - return $GLOBALS['oo-mode'] ? $fmt->formatCurrency( $number, $currency ) : numfmt_format_currency( $fmt, $number, $currency ); -} -function ut_nfmt_parse_currency( $fmt, $string, &$currency, &$position = null ) -{ - if(is_null($position)) { - return $GLOBALS['oo-mode'] ? $fmt->parseCurrency( $string, $currency ) : numfmt_parse_currency( $fmt, $string, $currency ); - } else { - return $GLOBALS['oo-mode'] ? $fmt->parseCurrency( $string, $currency, $position ) : numfmt_parse_currency( $fmt, $string, $currency, $position ); - } -} -function ut_nfmt_set_attribute( $fmt, $attribute, $value ) -{ - return $GLOBALS['oo-mode'] ? $fmt->setAttribute( $attribute, $value ) : numfmt_set_attribute( $fmt, $attribute, $value ); -} -function ut_nfmt_set_text_attribute( $fmt, $attribute, $value ) -{ - return $GLOBALS['oo-mode'] ? $fmt->setTextAttribute( $attribute, $value ) : numfmt_set_text_attribute( $fmt, $attribute, $value ); -} -function ut_nfmt_set_symbol( $fmt, $attribute, $value ) -{ - return $GLOBALS['oo-mode'] ? $fmt->setSymbol( $attribute, $value ) : numfmt_set_symbol( $fmt, $attribute, $value ); -} -function ut_nfmt_set_pattern( $fmt, $pattern ) -{ - return $GLOBALS['oo-mode'] ? $fmt->setPattern( $pattern ) : numfmt_set_pattern( $fmt, $pattern ); -} -function ut_nfmt_get_attribute( $fmt, $attribute ) -{ - return $GLOBALS['oo-mode'] ? $fmt->getAttribute( $attribute ) : numfmt_get_attribute( $fmt, $attribute ); -} -function ut_nfmt_get_text_attribute( $fmt, $attribute ) -{ - return $GLOBALS['oo-mode'] ? $fmt->getTextAttribute( $attribute ) : numfmt_get_text_attribute( $fmt, $attribute ); -} -function ut_nfmt_get_symbol( $fmt, $attribute ) -{ - return $GLOBALS['oo-mode'] ? $fmt->getSymbol( $attribute ) : numfmt_get_symbol( $fmt, $attribute ); -} -function ut_nfmt_get_pattern( $fmt ) -{ - return $GLOBALS['oo-mode'] ? $fmt->getPattern() : numfmt_get_pattern( $fmt ); -} -function ut_nfmt_get_locale( $fmt, $type = 0 ) -{ - return $GLOBALS['oo-mode'] ? $fmt->getLocale( $type ) : numfmt_get_locale( $fmt, $type ); -} -function ut_nfmt_get_error_code( $fmt ) -{ - return $GLOBALS['oo-mode'] ? $fmt->getErrorCode() : numfmt_get_error_code( $fmt ); -} -function ut_nfmt_get_error_message( $fmt ) -{ - return $GLOBALS['oo-mode'] ? $fmt->getErrorMessage() : numfmt_get_error_message( $fmt ); -} - -function ut_norm_normalize( $str, $form ) -{ - return $GLOBALS['oo-mode'] ? Normalizer::normalize( $str, $form ) : normalizer_normalize( $str, $form ); -} -function ut_norm_is_normalized( $str, $form ) -{ - return $GLOBALS['oo-mode'] ? Normalizer::isNormalized( $str, $form ) : normalizer_is_normalized( $str, $form ); -} - -/* - * Wrappers around Collator methods to run them in either OO- or procedural mode. - */ - -function ut_loc_get_default( ) -{ - return $GLOBALS['oo-mode'] ? Locale::getDefault( ) : locale_get_default(); -} -function ut_loc_set_default( $locale ) -{ - return $GLOBALS['oo-mode'] ? Locale::setDefault( $locale ) : locale_set_default( $locale ); -} -function ut_loc_get_primary_language( $locale ) -{ - return $GLOBALS['oo-mode'] ? Locale::getPrimaryLanguage( $locale ) : locale_get_primary_language( $locale ); -} -function ut_loc_get_script( $locale ) -{ - return $GLOBALS['oo-mode'] ? Locale::getScript( $locale ) : locale_get_script( $locale ); -} -function ut_loc_get_region( $locale ) -{ - return $GLOBALS['oo-mode'] ? Locale::getRegion( $locale ) : locale_get_region( $locale ); -} -function ut_loc_get_keywords( $locale ) -{ - return $GLOBALS['oo-mode'] ? Locale::getKeywords( $locale ) : locale_get_keywords( $locale ); -} -function ut_loc_get_display_name( $locale , $dispLocale ) -{ - return $GLOBALS['oo-mode'] ? Locale::getDisplayName( $locale , $dispLocale ) : locale_get_display_name( $locale , $dispLocale ); -} -function ut_loc_get_display_language( $locale , $dispLocale ) -{ - return $GLOBALS['oo-mode'] ? Locale::getDisplayLanguage( $locale , $dispLocale ) : locale_get_display_language( $locale , $dispLocale ); -} -function ut_loc_get_display_script( $locale , $dispLocale ) -{ - return $GLOBALS['oo-mode'] ? Locale::getDisplayScript( $locale , $dispLocale ) : locale_get_display_script( $locale , $dispLocale ); -} -function ut_loc_get_display_region( $locale, $dispLocale ) -{ - return $GLOBALS['oo-mode'] ? Locale::getDisplayRegion( $locale, $dispLocale ) : locale_get_display_region( $locale, $dispLocale ); -} -function ut_loc_get_display_variant( $locale , $dispLocale ) -{ - return $GLOBALS['oo-mode'] ? Locale::getDisplayVariant( $locale , $dispLocale ) : locale_get_display_variant( $locale, $dispLocale ); -} -function ut_loc_locale_compose( $loc_parts_arr ) -{ - return $GLOBALS['oo-mode'] ? Locale::composeLocale( $loc_parts_arr ) : locale_compose( $loc_parts_arr ); -} -function ut_loc_locale_parse( $locale ) -{ - return $GLOBALS['oo-mode'] ? Locale::parseLocale( $locale ) : locale_parse($locale ); -} -function ut_loc_locale_get_all_variants( $locale ) -{ - return $GLOBALS['oo-mode'] ? Locale::getAllVariants( $locale ) : locale_get_all_variants( $locale ); -} -function ut_loc_locale_filter_matches( $lang_tag,$loc_range ,$isCanonical) -{ - return $GLOBALS['oo-mode'] ? Locale::filterMatches( $lang_tag,$loc_range ,$isCanonical) : locale_filter_matches( $lang_tag,$loc_range ,$isCanonical); -} -function ut_loc_canonicalize( $locale ) -{ - return $GLOBALS['oo-mode'] ? Locale::canonicalize( $locale ) : locale_canonicalize( $locale ); -} -function ut_loc_locale_lookup( $lang_tag_arr,$loc_range,$isCanonical,$default_loc) -{ - return $GLOBALS['oo-mode'] ? Locale::lookup( $lang_tag_arr,$loc_range,$isCanonical,$default_loc ) : locale_lookup( $lang_tag_arr,$loc_range,$isCanonical,$default_loc ); -} -/* MessageFormatter functions */ -function ut_msgfmt_create( $locale, $pattern) -{ - return $GLOBALS['oo-mode'] ? MessageFormatter::create( $locale, $pattern ) : msgfmt_create( $locale, $pattern ); -} -function ut_msgfmt_format( $fmt, $args ) -{ - return $GLOBALS['oo-mode'] ? $fmt->format( $args ) : msgfmt_format( $fmt, $args); -} -function ut_msgfmt_parse( $fmt, $string) -{ - return $GLOBALS['oo-mode'] ? $fmt->parse( $string) : msgfmt_parse( $fmt, $string); -} -function ut_msgfmt_format_message( $locale, $pattern, $args ) -{ - return $GLOBALS['oo-mode'] ? MessageFormatter::formatMessage( $locale, $pattern, $args ) : msgfmt_format_message( $locale, $pattern, $args ); -} -function ut_msgfmt_parse_message( $locale, $pattern, $string ) -{ - return $GLOBALS['oo-mode'] ? MessageFormatter::parseMessage( $locale, $pattern, $string ) : msgfmt_parse_message( $locale, $pattern, $string ); -} -function ut_msgfmt_set_pattern( $fmt, $pattern ) -{ - return $GLOBALS['oo-mode'] ? $fmt->setPattern( $pattern ) : msgfmt_set_pattern( $fmt, $pattern ); -} -function ut_msgfmt_get_pattern( $fmt ) -{ - return $GLOBALS['oo-mode'] ? $fmt->getPattern() : msgfmt_get_pattern( $fmt ); -} -function ut_msgfmt_get_locale( $fmt ) -{ - return $GLOBALS['oo-mode'] ? $fmt->getLocale( ) : msgfmt_get_locale( $fmt ); -} -function ut_msgfmt_get_error_code( $fmt ) -{ - return $GLOBALS['oo-mode'] ? $fmt->getErrorCode() : msgfmt_get_error_code( $fmt ); -} -function ut_msgfmt_get_error_message( $fmt ) -{ - return $GLOBALS['oo-mode'] ? $fmt->getErrorMessage() : msgfmt_get_error_message( $fmt ); -} -/* IntlDateFormatter functions */ -function ut_datefmt_create( $locale, $datetype, $timetype, $timezone = null, $calendar = null ,$pattern = null) -{ - return $GLOBALS['oo-mode'] ? datefmt_create( $locale, $datetype, $timetype, $timezone, $calendar ,$pattern ) : datefmt_create( $locale, $datetype, $timetype, $timezone, $calendar ,$pattern); -} -function ut_datefmt_get_datetype( $fmt ) -{ - return $GLOBALS['oo-mode'] ? $fmt->getDateType( ) : datefmt_get_datetype( $fmt ); -} -function ut_datefmt_get_timetype( $fmt ) -{ - return $GLOBALS['oo-mode'] ? $fmt->getTimeType( ) : datefmt_get_timetype( $fmt ); -} -function ut_datefmt_get_calendar( $fmt ) -{ - return $GLOBALS['oo-mode'] ? $fmt->getCalendar( ) : datefmt_get_calendar( $fmt ); -} -function ut_datefmt_set_calendar( $fmt ,$calendar ) -{ - return $GLOBALS['oo-mode'] ? $fmt->setCalendar( $calendar ) : datefmt_set_calendar( $fmt , $calendar ); -} -function ut_datefmt_get_timezone_id( $fmt ) -{ - return $GLOBALS['oo-mode'] ? $fmt->getTimeZoneId( ) : datefmt_get_timezone_id( $fmt ); -} -function ut_datefmt_set_timezone_id( $fmt ,$timezone_id ) -{ - return $GLOBALS['oo-mode'] ? $fmt->setTimeZoneId( $timezone_id ) : datefmt_set_timezone_id( $fmt ,$timezone_id); -} -function ut_datefmt_get_pattern( $fmt ) -{ - return $GLOBALS['oo-mode'] ? $fmt->getPattern() : datefmt_get_pattern( $fmt ); -} -function ut_datefmt_set_pattern( $fmt , $pattern ) -{ - return $GLOBALS['oo-mode'] ? $fmt->setPattern( $pattern ) : datefmt_set_pattern( $fmt , $pattern); -} -function ut_datefmt_get_locale( $fmt ,$type=ULOC_ACTUAL_LOCALE) -{ - return $GLOBALS['oo-mode'] ? $fmt->getLocale($type ) : datefmt_get_locale( $fmt ,$type); -} -function ut_datefmt_is_lenient( $fmt ) -{ - return $GLOBALS['oo-mode'] ? $fmt->isLenient() : datefmt_is_lenient( $fmt ); -} -function ut_datefmt_set_lenient( $fmt , $lenient ) -{ - return $GLOBALS['oo-mode'] ? $fmt->setLenient( $lenient ) : datefmt_set_lenient( $fmt , $lenient); -} -function ut_datefmt_format( $fmt , $value ) -{ - return $GLOBALS['oo-mode'] ? $fmt->format( $value ) : datefmt_format( $fmt , $value); -} -function ut_datefmt_parse( $fmt , $value ,$parse_pos=0 ) -{ - return $GLOBALS['oo-mode'] ? $fmt->parse( $value ,$parse_pos ) : datefmt_parse( $fmt , $value,$parse_pos); -} -function ut_datefmt_localtime( $fmt , $value ,$parse_pos=0 ) -{ - return $GLOBALS['oo-mode'] ? $fmt->localtime( $value , $parse_pos ) : datefmt_localtime( $fmt , $value , $parse_pos ); -} -?> +<?php +/* + * Run unit test in OO- and in procedural mode. + * Then compare the outputs. + * It they're equal then show one of them. + * Otherwise indicate an error. + */ +function ut_run() +{ + // Run unit test in OO mode. + $GLOBALS['oo-mode'] = true; + $oo_result = ut_main(); + + // Run unit test in procedural mode. + $GLOBALS['oo-mode'] = false; + $proc_result = ut_main(); + + // Show error if the APIs produce different results. + if( $proc_result !== $oo_result ) + { + echo "ERROR: OO- and procedural APIs produce different results!\n"; + echo "OO API output:\n"; + echo str_repeat( '=', 78 ) . "\n"; + echo $oo_result; + echo str_repeat( '=', 78 ) . "\n"; + echo "procedural API output:\n"; + echo str_repeat( '=', 78 ) . "\n"; + echo $proc_result; + echo str_repeat( '=', 78 ) . "\n"; + return; + } + + // Else, if the results are equal, show one of them. + echo $proc_result; +} + +function dump( $val ) +{ + return var_export( $val, true ); +} + +/* + * Wrappers around Collator methods to run them in either OO- or procedural mode. + */ + +function ut_coll_create( $locale ) +{ + return $GLOBALS['oo-mode'] ? Collator::create( $locale ) : collator_create( $locale ); +} +function ut_coll_compare( $coll, $str1, $str2 ) +{ + return $GLOBALS['oo-mode'] ? $coll->compare( $str1, $str2 ) : collator_compare( $coll, $str1, $str2 ); +} +function ut_coll_sort( $coll, &$arr, $sort_flag = Collator::SORT_REGULAR ) +{ + return $GLOBALS['oo-mode'] ? $coll->sort( $arr, $sort_flag ) : collator_sort( $coll, $arr, $sort_flag ); +} +function ut_coll_sort_with_sort_keys( $coll, &$arr ) +{ + return $GLOBALS['oo-mode'] ? $coll->sortWithSortKeys( $arr ) : collator_sort_with_sort_keys( $coll, $arr ); +} +function ut_coll_asort( $coll, &$arr, $sort_flag = Collator::SORT_REGULAR ) +{ + return $GLOBALS['oo-mode'] ? $coll->asort( $arr, $sort_flag ) : collator_asort( $coll, $arr, $sort_flag ); +} +function ut_coll_get_locale( $coll, $type ) +{ + return $GLOBALS['oo-mode'] ? $coll->getLocale( $type ) : collator_get_locale( $coll, $type ); +} +function ut_coll_get_display_name( $obj_loc, $disp_loc ) +{ + return $GLOBALS['oo-mode'] ? Collator::getDisplayName( $obj_loc, $disp_loc ) : collator_get_display_name( $obj_loc, $disp_loc ); +} +function ut_coll_get_available_locales() +{ + return $GLOBALS['oo-mode'] ? Collator::getAvailableLocales() : collator_get_available_locales(); +} +function ut_coll_get_attribute( $coll, $attr ) +{ + return $GLOBALS['oo-mode'] ? $coll->getAttribute( $attr ) : collator_get_attribute( $coll, $attr ); +} +function ut_coll_get_strength( $coll ) +{ + return $GLOBALS['oo-mode'] ? $coll->getStrength() : collator_get_strength( $coll ); +} +function ut_coll_set_strength( $coll, $strength ) +{ + return $GLOBALS['oo-mode'] ? $coll->setStrength( $strength ) : collator_set_strength( $coll, $strength ); +} +function ut_coll_set_attribute( $coll, $attr, $val ) +{ + return $GLOBALS['oo-mode'] ? $coll->setAttribute( $attr, $val ) : collator_set_attribute( $coll, $attr, $val ); +} +function ut_coll_get_variable_top( $coll ) +{ + return $GLOBALS['oo-mode'] ? $coll->getVariableTop() : collator_get_variable_top( $coll ); +} +function ut_coll_set_variable_top( $coll, $var_top ) +{ + return $GLOBALS['oo-mode'] ? $coll->setVariableTop( $var_top ) : collator_set_variable_top( $coll, $var_top ); +} +function ut_coll_restore_variable_top( $coll, $var_top ) +{ + return $GLOBALS['oo-mode'] ? $coll->restoreVariableTop( $var_top ) : collator_restore_variable_top( $coll, $var_top ); +} +function ut_coll_get_error_code( $coll ) +{ + return $GLOBALS['oo-mode'] ? $coll->getErrorCode() : collator_get_error_code( $coll ); +} +function ut_coll_get_error_message( $coll ) +{ + return $GLOBALS['oo-mode'] ? $coll->getErrorMessage() : collator_get_error_message( $coll ); +} +function ut_coll_get_default() +{ + return $GLOBALS['oo-mode'] ? Collator::getDefault() : collator_get_default(); +} +function ut_coll_set_default( $coll ) +{ + return $GLOBALS['oo-mode'] ? Collator::setDefault( $coll ) : collator_set_default( $coll ); +} + +/* + * Wrappers around NumberFormatter methods to run them in either OO- or procedural mode. + */ + +// FIXME: incomplete list + +function ut_nfmt_create( $locale, $style, $pattern = null ) +{ + return $GLOBALS['oo-mode'] ? new NumberFormatter( $locale, $style, $pattern ) : numfmt_create( $locale, $style, $pattern ); +} +function ut_nfmt_format( $fmt, $number, $type = null ) +{ + return $GLOBALS['oo-mode'] ? $fmt->format( $number, $type ) : numfmt_format( $fmt, $number, $type ); +} +function ut_nfmt_parse( $fmt, $string, $type = NumberFormatter::TYPE_DOUBLE, &$position = null ) +{ + if(is_null($position)) { + return $GLOBALS['oo-mode'] ? $fmt->parse( $string, $type ) : numfmt_parse( $fmt, $string, $type ); + } else { + return $GLOBALS['oo-mode'] ? $fmt->parse( $string, $type, $position ) : numfmt_parse( $fmt, $string, $type, $position ); + } +} +function ut_nfmt_format_currency( $fmt, $number, $currency ) +{ + return $GLOBALS['oo-mode'] ? $fmt->formatCurrency( $number, $currency ) : numfmt_format_currency( $fmt, $number, $currency ); +} +function ut_nfmt_parse_currency( $fmt, $string, &$currency, &$position = null ) +{ + if(is_null($position)) { + return $GLOBALS['oo-mode'] ? $fmt->parseCurrency( $string, $currency ) : numfmt_parse_currency( $fmt, $string, $currency ); + } else { + return $GLOBALS['oo-mode'] ? $fmt->parseCurrency( $string, $currency, $position ) : numfmt_parse_currency( $fmt, $string, $currency, $position ); + } +} +function ut_nfmt_set_attribute( $fmt, $attribute, $value ) +{ + return $GLOBALS['oo-mode'] ? $fmt->setAttribute( $attribute, $value ) : numfmt_set_attribute( $fmt, $attribute, $value ); +} +function ut_nfmt_set_text_attribute( $fmt, $attribute, $value ) +{ + return $GLOBALS['oo-mode'] ? $fmt->setTextAttribute( $attribute, $value ) : numfmt_set_text_attribute( $fmt, $attribute, $value ); +} +function ut_nfmt_set_symbol( $fmt, $attribute, $value ) +{ + return $GLOBALS['oo-mode'] ? $fmt->setSymbol( $attribute, $value ) : numfmt_set_symbol( $fmt, $attribute, $value ); +} +function ut_nfmt_set_pattern( $fmt, $pattern ) +{ + return $GLOBALS['oo-mode'] ? $fmt->setPattern( $pattern ) : numfmt_set_pattern( $fmt, $pattern ); +} +function ut_nfmt_get_attribute( $fmt, $attribute ) +{ + return $GLOBALS['oo-mode'] ? $fmt->getAttribute( $attribute ) : numfmt_get_attribute( $fmt, $attribute ); +} +function ut_nfmt_get_text_attribute( $fmt, $attribute ) +{ + return $GLOBALS['oo-mode'] ? $fmt->getTextAttribute( $attribute ) : numfmt_get_text_attribute( $fmt, $attribute ); +} +function ut_nfmt_get_symbol( $fmt, $attribute ) +{ + return $GLOBALS['oo-mode'] ? $fmt->getSymbol( $attribute ) : numfmt_get_symbol( $fmt, $attribute ); +} +function ut_nfmt_get_pattern( $fmt ) +{ + return $GLOBALS['oo-mode'] ? $fmt->getPattern() : numfmt_get_pattern( $fmt ); +} +function ut_nfmt_get_locale( $fmt, $type = 0 ) +{ + return $GLOBALS['oo-mode'] ? $fmt->getLocale( $type ) : numfmt_get_locale( $fmt, $type ); +} +function ut_nfmt_get_error_code( $fmt ) +{ + return $GLOBALS['oo-mode'] ? $fmt->getErrorCode() : numfmt_get_error_code( $fmt ); +} +function ut_nfmt_get_error_message( $fmt ) +{ + return $GLOBALS['oo-mode'] ? $fmt->getErrorMessage() : numfmt_get_error_message( $fmt ); +} + +function ut_norm_normalize( $str, $form ) +{ + return $GLOBALS['oo-mode'] ? Normalizer::normalize( $str, $form ) : normalizer_normalize( $str, $form ); +} +function ut_norm_is_normalized( $str, $form ) +{ + return $GLOBALS['oo-mode'] ? Normalizer::isNormalized( $str, $form ) : normalizer_is_normalized( $str, $form ); +} + +/* + * Wrappers around Collator methods to run them in either OO- or procedural mode. + */ + +function ut_loc_get_default( ) +{ + return $GLOBALS['oo-mode'] ? Locale::getDefault( ) : locale_get_default(); +} +function ut_loc_set_default( $locale ) +{ + return $GLOBALS['oo-mode'] ? Locale::setDefault( $locale ) : locale_set_default( $locale ); +} +function ut_loc_get_primary_language( $locale ) +{ + return $GLOBALS['oo-mode'] ? Locale::getPrimaryLanguage( $locale ) : locale_get_primary_language( $locale ); +} +function ut_loc_get_script( $locale ) +{ + return $GLOBALS['oo-mode'] ? Locale::getScript( $locale ) : locale_get_script( $locale ); +} +function ut_loc_get_region( $locale ) +{ + return $GLOBALS['oo-mode'] ? Locale::getRegion( $locale ) : locale_get_region( $locale ); +} +function ut_loc_get_keywords( $locale ) +{ + return $GLOBALS['oo-mode'] ? Locale::getKeywords( $locale ) : locale_get_keywords( $locale ); +} +function ut_loc_get_display_name( $locale , $dispLocale ) +{ + return $GLOBALS['oo-mode'] ? Locale::getDisplayName( $locale , $dispLocale ) : locale_get_display_name( $locale , $dispLocale ); +} +function ut_loc_get_display_language( $locale , $dispLocale ) +{ + return $GLOBALS['oo-mode'] ? Locale::getDisplayLanguage( $locale , $dispLocale ) : locale_get_display_language( $locale , $dispLocale ); +} +function ut_loc_get_display_script( $locale , $dispLocale ) +{ + return $GLOBALS['oo-mode'] ? Locale::getDisplayScript( $locale , $dispLocale ) : locale_get_display_script( $locale , $dispLocale ); +} +function ut_loc_get_display_region( $locale, $dispLocale ) +{ + return $GLOBALS['oo-mode'] ? Locale::getDisplayRegion( $locale, $dispLocale ) : locale_get_display_region( $locale, $dispLocale ); +} +function ut_loc_get_display_variant( $locale , $dispLocale ) +{ + return $GLOBALS['oo-mode'] ? Locale::getDisplayVariant( $locale , $dispLocale ) : locale_get_display_variant( $locale, $dispLocale ); +} +function ut_loc_locale_compose( $loc_parts_arr ) +{ + return $GLOBALS['oo-mode'] ? Locale::composeLocale( $loc_parts_arr ) : locale_compose( $loc_parts_arr ); +} +function ut_loc_locale_parse( $locale ) +{ + return $GLOBALS['oo-mode'] ? Locale::parseLocale( $locale ) : locale_parse($locale ); +} +function ut_loc_locale_get_all_variants( $locale ) +{ + return $GLOBALS['oo-mode'] ? Locale::getAllVariants( $locale ) : locale_get_all_variants( $locale ); +} +function ut_loc_locale_filter_matches( $lang_tag,$loc_range ,$isCanonical) +{ + return $GLOBALS['oo-mode'] ? Locale::filterMatches( $lang_tag,$loc_range ,$isCanonical) : locale_filter_matches( $lang_tag,$loc_range ,$isCanonical); +} +function ut_loc_canonicalize( $locale ) +{ + return $GLOBALS['oo-mode'] ? Locale::canonicalize( $locale ) : locale_canonicalize( $locale ); +} +function ut_loc_locale_lookup( $lang_tag_arr,$loc_range,$isCanonical,$default_loc) +{ + return $GLOBALS['oo-mode'] ? Locale::lookup( $lang_tag_arr,$loc_range,$isCanonical,$default_loc ) : locale_lookup( $lang_tag_arr,$loc_range,$isCanonical,$default_loc ); +} +/* MessageFormatter functions */ +function ut_msgfmt_create( $locale, $pattern) +{ + return $GLOBALS['oo-mode'] ? MessageFormatter::create( $locale, $pattern ) : msgfmt_create( $locale, $pattern ); +} +function ut_msgfmt_format( $fmt, $args ) +{ + return $GLOBALS['oo-mode'] ? $fmt->format( $args ) : msgfmt_format( $fmt, $args); +} +function ut_msgfmt_parse( $fmt, $string) +{ + return $GLOBALS['oo-mode'] ? $fmt->parse( $string) : msgfmt_parse( $fmt, $string); +} +function ut_msgfmt_format_message( $locale, $pattern, $args ) +{ + return $GLOBALS['oo-mode'] ? MessageFormatter::formatMessage( $locale, $pattern, $args ) : msgfmt_format_message( $locale, $pattern, $args ); +} +function ut_msgfmt_parse_message( $locale, $pattern, $string ) +{ + return $GLOBALS['oo-mode'] ? MessageFormatter::parseMessage( $locale, $pattern, $string ) : msgfmt_parse_message( $locale, $pattern, $string ); +} +function ut_msgfmt_set_pattern( $fmt, $pattern ) +{ + return $GLOBALS['oo-mode'] ? $fmt->setPattern( $pattern ) : msgfmt_set_pattern( $fmt, $pattern ); +} +function ut_msgfmt_get_pattern( $fmt ) +{ + return $GLOBALS['oo-mode'] ? $fmt->getPattern() : msgfmt_get_pattern( $fmt ); +} +function ut_msgfmt_get_locale( $fmt ) +{ + return $GLOBALS['oo-mode'] ? $fmt->getLocale( ) : msgfmt_get_locale( $fmt ); +} +function ut_msgfmt_get_error_code( $fmt ) +{ + return $GLOBALS['oo-mode'] ? $fmt->getErrorCode() : msgfmt_get_error_code( $fmt ); +} +function ut_msgfmt_get_error_message( $fmt ) +{ + return $GLOBALS['oo-mode'] ? $fmt->getErrorMessage() : msgfmt_get_error_message( $fmt ); +} +/* IntlDateFormatter functions */ +function ut_datefmt_create( $locale, $datetype, $timetype, $timezone = null, $calendar = null ,$pattern = null) +{ + return $GLOBALS['oo-mode'] ? datefmt_create( $locale, $datetype, $timetype, $timezone, $calendar ,$pattern ) : datefmt_create( $locale, $datetype, $timetype, $timezone, $calendar ,$pattern); +} +function ut_datefmt_get_datetype( $fmt ) +{ + return $GLOBALS['oo-mode'] ? $fmt->getDateType( ) : datefmt_get_datetype( $fmt ); +} +function ut_datefmt_get_timetype( $fmt ) +{ + return $GLOBALS['oo-mode'] ? $fmt->getTimeType( ) : datefmt_get_timetype( $fmt ); +} +function ut_datefmt_get_calendar( $fmt ) +{ + return $GLOBALS['oo-mode'] ? $fmt->getCalendar( ) : datefmt_get_calendar( $fmt ); +} +function ut_datefmt_set_calendar( $fmt ,$calendar ) +{ + return $GLOBALS['oo-mode'] ? $fmt->setCalendar( $calendar ) : datefmt_set_calendar( $fmt , $calendar ); +} +function ut_datefmt_get_timezone_id( $fmt ) +{ + return $GLOBALS['oo-mode'] ? $fmt->getTimeZoneId( ) : datefmt_get_timezone_id( $fmt ); +} +function ut_datefmt_set_timezone_id( $fmt ,$timezone_id ) +{ + return $GLOBALS['oo-mode'] ? $fmt->setTimeZoneId( $timezone_id ) : datefmt_set_timezone_id( $fmt ,$timezone_id); +} +function ut_datefmt_get_pattern( $fmt ) +{ + return $GLOBALS['oo-mode'] ? $fmt->getPattern() : datefmt_get_pattern( $fmt ); +} +function ut_datefmt_set_pattern( $fmt , $pattern ) +{ + return $GLOBALS['oo-mode'] ? $fmt->setPattern( $pattern ) : datefmt_set_pattern( $fmt , $pattern); +} +function ut_datefmt_get_locale( $fmt ,$type=ULOC_ACTUAL_LOCALE) +{ + return $GLOBALS['oo-mode'] ? $fmt->getLocale($type ) : datefmt_get_locale( $fmt ,$type); +} +function ut_datefmt_is_lenient( $fmt ) +{ + return $GLOBALS['oo-mode'] ? $fmt->isLenient() : datefmt_is_lenient( $fmt ); +} +function ut_datefmt_set_lenient( $fmt , $lenient ) +{ + return $GLOBALS['oo-mode'] ? $fmt->setLenient( $lenient ) : datefmt_set_lenient( $fmt , $lenient); +} +function ut_datefmt_format( $fmt , $value ) +{ + return $GLOBALS['oo-mode'] ? $fmt->format( $value ) : datefmt_format( $fmt , $value); +} +function ut_datefmt_parse( $fmt , $value , &$parse_pos=0 ) +{ + return $GLOBALS['oo-mode'] ? $fmt->parse( $value ,$parse_pos ) : datefmt_parse( $fmt , $value,$parse_pos); +} +function ut_datefmt_localtime( $fmt , $value , &$parse_pos=0 ) +{ + return $GLOBALS['oo-mode'] ? $fmt->localtime( $value , $parse_pos ) : datefmt_localtime( $fmt , $value , $parse_pos ); +} +?>
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php