Merge branch 'PHP-5.5' into PHP-5.6

* PHP-5.5:
  split msgfmt_format_intlcalendar_variant*.phpt for ICU 54.1
  split formatter_format*.phpt for ICP 54.1
  split dateformat_timezone_arg_variations*.phpt for ICU 54.1
  split dateformat_get_set_timezone_variant*.phpt for ICU 54.1
  fix icu version to test
  split ext/intl/tests/dateformat_get_set_calendar_variant*.phpt for 54.1
  split dateformat_formatObject_datetime_variant*.phpt for ICU 54.1
  split dateformat_formatObject_calendar_variant*.phpt for ICU 54.1
  split dateformat_create_cal_arg_variant2.phpt for ICU 53.1 and 54.1
  clone dateformat_calendars_variant3.phpt for ICU 54.1
  split collator_get_sort_key_variant3.phpt for icu 54.1
  split ext/intl/tests/collator_create3.phpt for icu >= 54.1

Conflicts:
	ext/intl/tests/dateformat_create_cal_arg_variant3.phpt
	ext/intl/tests/dateformat_formatObject_calendar_variant3.phpt
	ext/intl/tests/dateformat_formatObject_datetime_variant3.phpt
	ext/intl/tests/dateformat_get_set_calendar_variant3.phpt
	ext/intl/tests/dateformat_get_set_timezone_variant3.phpt
	ext/intl/tests/dateformat_timezone_arg_variations3.phpt
	ext/intl/tests/msgfmt_format_intlcalendar_variant3.phpt
This commit is contained in:
Anatol Belski 2014-11-20 13:36:37 +01:00
commit e25b23d1c9
22 changed files with 685 additions and 3 deletions

View File

@ -1,8 +1,9 @@
--TEST--
create() icu >= 53.1
create() icu >= 53.1 && icu < 54.1
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
<?php if (version_compare(INTL_ICU_VERSION, '53.1') < 0) die('skip for ICU >= 53.1'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '54.1') >= 0) die('skip for ICU < 54.1'); ?>
--FILE--
<?php

View File

@ -0,0 +1,79 @@
--TEST--
create() icu >= 53.1
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
<?php if (version_compare(INTL_ICU_VERSION, '54.1') < 0) die('skip for ICU >= 54.1'); ?>
--FILE--
<?php
/*
* Try creating collator with different locales
* with Procedural and Object methods.
*/
function ut_main()
{
$res_str = '';
$locales = array(
'EN-US-ODESSA',
'UK_UA_ODESSA',
'uk-ua_CALIFORNIA@currency=;currency=GRN',
'',
'root',
'uk@currency=EURO',
'1234567891113151719212325272931333537394143454749515357596163656769717375777981838587899193959799'
);
foreach( $locales as $locale )
{
// Create Collator with the current locale.
$coll = ut_coll_create( $locale );
if( !is_object($coll) )
{
$res_str .= "Error creating collator with '$locale' locale: " .
intl_get_error_message() . "\n";
continue;
}
// Get the requested, valid and actual locales.
$vloc = ut_coll_get_locale( $coll, Locale::VALID_LOCALE );
$aloc = ut_coll_get_locale( $coll, Locale::ACTUAL_LOCALE );
// Show them.
$res_str .= "Locale: '$locale'\n" .
" ULOC_REQUESTED_LOCALE = '$locale'\n" .
" ULOC_VALID_LOCALE = '$vloc'\n" .
" ULOC_ACTUAL_LOCALE = '$aloc'\n";
}
return $res_str;
}
include_once( 'ut_common.inc' );
ut_run();
?>
--EXPECTF--
Locale: 'EN-US-ODESSA'
ULOC_REQUESTED_LOCALE = 'EN-US-ODESSA'
ULOC_VALID_LOCALE = 'en_US'
ULOC_ACTUAL_LOCALE = 'root'
Locale: 'UK_UA_ODESSA'
ULOC_REQUESTED_LOCALE = 'UK_UA_ODESSA'
ULOC_VALID_LOCALE = 'uk'
ULOC_ACTUAL_LOCALE = 'uk'
Error creating collator with 'uk-ua_CALIFORNIA@currency=;currency=GRN' locale: collator_create: unable to open ICU collator: U_ILLEGAL_ARGUMENT_ERROR
Locale: ''
ULOC_REQUESTED_LOCALE = ''
ULOC_VALID_LOCALE = '%s'
ULOC_ACTUAL_LOCALE = '%s'
Locale: 'root'
ULOC_REQUESTED_LOCALE = 'root'
ULOC_VALID_LOCALE = 'root'
ULOC_ACTUAL_LOCALE = 'root'
Locale: 'uk@currency=EURO'
ULOC_REQUESTED_LOCALE = 'uk@currency=EURO'
ULOC_VALID_LOCALE = 'uk'
ULOC_ACTUAL_LOCALE = 'uk'
Error creating collator with '1234567891113151719212325272931333537394143454749515357596163656769717375777981838587899193959799' locale: Locale string too long, should be no longer than 80 characters: U_ILLEGAL_ARGUMENT_ERROR

View File

@ -1,8 +1,9 @@
--TEST--
collator_get_sort_key()
collator_get_sort_key() icu >= 53.1 && icu < 54.1
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
<?php if (version_compare(INTL_ICU_VERSION, '53.1') < 0) die('skip for ICU >= 53.1'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '54.1') >= 0) die('skip for ICU < 54.1'); ?>
--FILE--
<?php

View File

@ -0,0 +1,98 @@
--TEST--
collator_get_sort_key() icu >= 54.1
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
<?php if (version_compare(INTL_ICU_VERSION, '54.1') < 0) die('skip for ICU >= 54.1'); ?>
--FILE--
<?php
/*
* Get sort keys using various locales
*/
function sort_arrays( $locale, $data )
{
$res_str = '';
$coll = ut_coll_create( $locale );
foreach($data as $value) {
$res_val = ut_coll_get_sort_key( $coll, $value );
$res_str .= "source: ".$value."\n".
"key: ".bin2hex($res_val)."\n";
}
return $res_str;
}
function ut_main()
{
$res_str = '';
// Regular strings keys
$test_params = array(
'abc', 'abd', 'aaa',
'аа', 'а', 'z',
'', null , '3',
'y' , 'i' , 'k'
);
$res_str .= sort_arrays( 'en_US', $test_params );
// Sort a non-ASCII array using ru_RU locale.
$test_params = array(
'абг', 'абв', 'жжж', 'эюя'
);
$res_str .= sort_arrays( 'ru_RU', $test_params );
// Sort an array using Lithuanian locale.
$res_str .= sort_arrays( 'lt_LT', $test_params );
return $res_str . "\n";
}
include_once( 'ut_common.inc' );
ut_run();
?>
--EXPECT--
source: abc
key: 292b2d01070107
source: abd
key: 292b2f01070107
source: aaa
key: 29292901070107
source: аа
key: 5e060601060106
source: а
key: 5e0601050105
source: z
key: 5b01050105
source:
key: 0101
source:
key: 0101
source: 3
key: 1a01050105
source: y
key: 5901050105
source: i
key: 3901050105
source: k
key: 3d01050105
source: абг
key: 2806101401070107
source: абв
key: 2806101201070107
source: жжж
key: 2830303001070107
source: эюя
key: 28ccd0d401070107
source: абг
key: 5e06101401070107
source: абв
key: 5e06101201070107
source: жжж
key: 5e30303001070107
source: эюя
key: 5eccd0d401070107

View File

@ -6,6 +6,7 @@ date.timezone=Atlantic/Azores
<?php
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0) die('skip for ICU >= 51.2'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '54.1') >= 0) die('skip for ICU < 54.1'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);

View File

@ -0,0 +1,45 @@
--TEST--
IntlDateFormatter, calendars and time zone
--INI--
date.timezone=Atlantic/Azores
--SKIPIF--
<?php
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '54.1') < 0) die('skip for ICU >= 54.1'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
$fmt1 = new IntlDateFormatter('en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'GMT+05:12',
IntlDateFormatter::TRADITIONAL);
$fmt2 = new IntlDateFormatter('en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'GMT+05:12',
IntlDateFormatter::GREGORIAN);
$fmt3 = new IntlDateFormatter('en_US@calendar=hebrew',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'GMT+05:12',
IntlDateFormatter::TRADITIONAL);
var_dump($fmt1->format(strtotime('2012-01-01 00:00:00 +0000')));
var_dump($fmt2->format(strtotime('2012-01-01 00:00:00 +0000')));
var_dump($fmt3->format(strtotime('2012-01-01 00:00:00 +0000')));
new IntlDateFormatter('en_US@calendar=hebrew',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'GMT+05:12',
-1);
?>
==DONE==
--EXPECTF--
string(47) "Sunday, January 1, 2012 at 5:12:00 AM GMT+05:12"
string(47) "Sunday, January 1, 2012 at 5:12:00 AM GMT+05:12"
string(44) "Sunday, 6 Tevet 5772 at 5:12:00 AM GMT+05:12"
Warning: IntlDateFormatter::__construct(): datefmt_create: invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object in %sdateformat_calendars_variant%d.php on line %d
==DONE==

View File

@ -4,6 +4,7 @@ IntlDateFormatter: several forms of the calendar arg
<?php
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '52.1') < 0) die('skip for ICU >= 52.1'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '54.1') >= 0) die('skip for ICU < 54.1'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);

View File

@ -0,0 +1,53 @@
--TEST--
IntlDateFormatter: several forms of the calendar arg
--SKIPIF--
<?php
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '54.1') < 0) die('skip for ICU >= 54.1'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
ini_set("intl.default_locale", "pt_PT");
ini_set("date.timezone", 'Atlantic/Azores');
$ts = strtotime('2012-01-01 00:00:00 UTC');
$cal = new IntlGregorianCalendar('UTC', NULL);
$df = new IntlDateFormatter('es_ES', 0, 0, NULL, $cal);
echo $df->format($ts), "\n";
$cal = IntlCalendar::createInstance('UTC', 'en@calendar=islamic');
$df = new IntlDateFormatter('es_ES', 0, 0, NULL, $cal);
echo $df->format($ts), "\n";
//override calendar's timezone
$cal = new IntlGregorianCalendar('UTC', NULL);
$df = new IntlDateFormatter('es_ES', 0, 0, 'Europe/Madrid', $cal);
echo $df->format($ts), "\n";
//default calendar is gregorian
$df = new IntlDateFormatter('es_ES@calendar=islamic', 0, 0);
echo $df->format($ts), "\n";
//try now with traditional
$df = new IntlDateFormatter('es_ES@calendar=islamic', 0, 0, NULL, IntlDateFormatter::TRADITIONAL);
echo $df->format($ts), "\n";
//the timezone can be overridden when not specifying a calendar
$df = new IntlDateFormatter('es_ES@calendar=islamic', 0, 0, 'UTC', IntlDateFormatter::TRADITIONAL);
echo $df->format($ts), "\n";
$df = new IntlDateFormatter('es_ES', 0, 0, 'UTC', 0);
echo $df->format($ts), "\n";
?>
==DONE==
--EXPECTF--
domingo%S 1 de enero de 2012, 0:00:00 (GMT)
domingo%S 8 de Safar de 1433, 0:00:00 (GMT)
domingo, 1 de enero de 2012, 1:00:00 (hora estándar de Europa central)
sábado, 31 de diciembre de 2011 d. C., 23:00:00 (hora estándar de las Azores)
sábado, 7 de Safar de 1433 AH, 23:00:00 (hora estándar de las Azores)
domingo%S 8 de Safar de 1433 AH, 0:00:00 (GMT)
domingo%S 1 de enero de 2012, 0:00:00 (GMT)
==DONE==

View File

@ -4,6 +4,7 @@ IntlDateFormatter::formatObject(): IntlCalendar tests
<?php
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '52.1') < 0) die('skip for ICU >= 52.1'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '54.1') >= 0) die('skip for ICU < 54.1'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);

View File

@ -0,0 +1,40 @@
--TEST--
IntlDateFormatter::formatObject(): IntlCalendar tests
--SKIPIF--
<?php
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '54.1') < 0) die('skip for ICU >= 54.1'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
ini_set("intl.default_locale", "pt_PT");
ini_set("date.timezone", "Europe/Lisbon");
$cal = IntlCalendar::fromDateTime('2012-01-01 00:00:00'); //Europe/Lisbon
echo IntlDateFormatter::formatObject($cal), "\n";
echo IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL), "\n";
echo IntlDateFormatter::formatObject($cal, null, "en-US"), "\n";
echo IntlDateFormatter::formatObject($cal, array(IntlDateFormatter::SHORT, IntlDateFormatter::FULL), "en-US"), "\n";
echo IntlDateFormatter::formatObject($cal, 'E y-MM-d HH,mm,ss.SSS v', "en-US"), "\n";
$cal = IntlCalendar::fromDateTime('2012-01-01 05:00:00+03:00');
echo datefmt_format_object($cal, IntlDateFormatter::FULL), "\n";
$cal = IntlCalendar::createInstance(null,'en-US@calendar=islamic-civil');
$cal->setTime(strtotime('2012-01-01 00:00:00')*1000.);
echo IntlDateFormatter::formatObject($cal), "\n";
echo IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL, "en-US"), "\n";
?>
==DONE==
--EXPECTF--
01/01/2012, 00:00:00
domingo, 1 de janeiro de 2012 às 00:00:00 Hora Padrão %Sda Europa Ocidental
Jan 1, 2012, 12:00:00 AM
1/1/12, 12:00:00 AM Western European Standard %STime
Sun 2012-01-1 00,00,00.000 Portugal Time
domingo, 1 de janeiro de 2012 às 05:00:00 GMT+03:00
06/02/1433, 00:00:00
Sunday, Safar 6, 1433 at 12:00:00 AM Western European Standard Time
==DONE==

View File

@ -4,6 +4,7 @@ IntlDateFormatter::formatObject(): DateTime tests
<?php
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '52.1') < 0) die('skip for ICU >= 52.1'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '54.1') >= 0) die('skip for ICU < 54.1'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);

View File

@ -0,0 +1,33 @@
--TEST--
IntlDateFormatter::formatObject(): DateTime tests
--SKIPIF--
<?php
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '54.1') < 0) die('skip for ICU >= 54.1'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
ini_set("intl.default_locale", "pt_PT");
ini_set("date.timezone", "Europe/Lisbon");
$dt = new DateTime('2012-01-01 00:00:00'); //Europe/Lisbon
echo IntlDateFormatter::formatObject($dt), "\n";
echo IntlDateFormatter::formatObject($dt, IntlDateFormatter::FULL), "\n";
echo IntlDateFormatter::formatObject($dt, null, "en-US"), "\n";
echo IntlDateFormatter::formatObject($dt, array(IntlDateFormatter::SHORT, IntlDateFormatter::FULL), "en-US"), "\n";
echo IntlDateFormatter::formatObject($dt, 'E y-MM-d HH,mm,ss.SSS v', "en-US"), "\n";
$dt = new DateTime('2012-01-01 05:00:00+03:00');
echo IntlDateFormatter::formatObject($dt, IntlDateFormatter::FULL), "\n";
?>
==DONE==
--EXPECTF--
01/01/2012, 00:00:00
domingo, 1 de janeiro de 2012 às 00:00:00 Hora Padrão %Sda Europa Ocidental
Jan 1, 2012, 12:00:00 AM
1/1/12, 12:00:00 AM Western European Standard %STime
Sun 2012-01-1 00,00,00.000 Portugal Time
domingo, 1 de janeiro de 2012 às 05:00:00 GMT+03:00
==DONE==

View File

@ -4,6 +4,7 @@ IntlDateFormatter: setCalendar()/getCalendar()/getCalendarObject()
<?php
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '52.1') < 0) die('skip for ICU >= 52.1'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '54.1') >= 0) die('skip for ICU < 54.1'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);

View File

@ -0,0 +1,55 @@
--TEST--
IntlDateFormatter: setCalendar()/getCalendar()/getCalendarObject()
--SKIPIF--
<?php
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '54.1') < 0) die('skip for ICU >= 54.1'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
ini_set("intl.default_locale", "pt_PT");
ini_set("date.timezone", 'Atlantic/Azores');
$ts = strtotime('2012-01-01 00:00:00 UTC');
function d(IntlDateFormatter $df) {
global $ts;
echo $df->format($ts), "\n";
var_dump($df->getCalendar(),
$df->getCalendarObject()->getType(),
$df->getCalendarObject()->getTimeZone()->getId());
echo "\n";
}
$df = new IntlDateFormatter('fr@calendar=islamic', 0, 0, 'Europe/Minsk');
d($df);
//changing the calendar with a cal type should not change tz
$df->setCalendar(IntlDateFormatter::TRADITIONAL);
d($df);
//but changing with an actual calendar should
$cal = IntlCalendar::createInstance("UTC");
$df->setCalendar($cal);
d($df);
?>
==DONE==
--EXPECT--
dimanche 1 janvier 2012 ap. J.-C. à 03:00:00 heure de Kaliningrad
int(1)
string(9) "gregorian"
string(12) "Europe/Minsk"
dimanche 8 safar 1433 AH à 03:00:00 heure de Kaliningrad
int(0)
string(7) "islamic"
string(12) "Europe/Minsk"
dimanche 1 janvier 2012 ap. J.-C. à 00:00:00 UTC
bool(false)
string(9) "gregorian"
string(3) "UTC"
==DONE==

View File

@ -4,6 +4,7 @@ IntlDateFormatter: get/setTimeZone()
<?php
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '52.1') < 0) die('skip for ICU >= 52.1'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '54.1') >= 0) die('skip for ICU < 54.1'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);

View File

@ -0,0 +1,62 @@
--TEST--
IntlDateFormatter: get/setTimeZone()
--SKIPIF--
<?php
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '54.1') < 0) die('skip for ICU >= 54.1'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
ini_set("intl.default_locale", "pt_PT");
ini_set("date.timezone", 'Atlantic/Azores');
$ts = strtotime('2012-01-01 00:00:00 UTC');
function d(IntlDateFormatter $df) {
global $ts;
echo $df->format($ts), "\n";
var_dump(
$df->getTimeZoneID(),
$df->getTimeZone()->getID());
echo "\n";
}
$df = new IntlDateFormatter('pt_PT', 0, 0, 'Europe/Minsk');
d($df);
$df->setTimeZone(NULL);
d($df);
$df->setTimeZone('Europe/Madrid');
d($df);
$df->setTimeZone(IntlTimeZone::createTimeZone('Europe/Paris'));
d($df);
$df->setTimeZone(new DateTimeZone('Europe/Amsterdam'));
d($df);
?>
==DONE==
--EXPECTF--
domingo, 1 de janeiro de 2012 às 03:00:00 Hor%s do Extremo Leste da Europa
string(12) "Europe/Minsk"
string(12) "Europe/Minsk"
sábado, 31 de dezembro de 2011 às 23:00:00 Hor%s Padrão %Sdos Açores
string(15) "Atlantic/Azores"
string(15) "Atlantic/Azores"
domingo, 1 de janeiro de 2012 às 01:00:00 Hor%s Padrão %Sda Europa Central
string(13) "Europe/Madrid"
string(13) "Europe/Madrid"
domingo, 1 de janeiro de 2012 às 01:00:00 Hor%s Padrão %Sda Europa Central
string(12) "Europe/Paris"
string(12) "Europe/Paris"
domingo, 1 de janeiro de 2012 às 01:00:00 Hor%s Padrão %Sda Europa Central
string(16) "Europe/Amsterdam"
string(16) "Europe/Amsterdam"
==DONE==

View File

@ -4,6 +4,7 @@ IntlDateFormatter: several forms of the timezone arg
<?php
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '52.1') < 0) die('skip for ICU >= 52.1'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '54.1') >= 0) die('skip for ICU < 54.1'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);

View File

@ -0,0 +1,46 @@
--TEST--
IntlDateFormatter: several forms of the timezone arg
--SKIPIF--
<?php
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '54.1') < 0) die('skip for ICU >= 54.1'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
ini_set("date.timezone", 'Atlantic/Azores');
$ts = strtotime('2012-01-01 00:00:00 UTC');
//should use Atlantic/Azores
$df = new IntlDateFormatter('es_ES', 0, 0, NULL);
echo $df->format($ts), "\n";
$df = new IntlDateFormatter('es_ES', 0, 0, 'Europe/Amsterdam');
echo $df->format($ts), "\n";
$df = new IntlDateFormatter('es_ES', 0, 0, new DateTimeZone('Europe/Lisbon'));
echo $df->format($ts), "\n";
$df = new IntlDateFormatter('es_ES', 0, 0, IntlTimeZone::createTimeZone('America/New_York'));
echo $df->format($ts), "\n";
//time zone has priority
$df = new IntlDateFormatter('es_ES', 0, 0, 'Europe/Amsterdam', new IntlGregorianCalendar('Europe/Lisbon'));
echo $df->format($ts), "\n";
//calendar has priority
$df = new IntlDateFormatter('es_ES', 0, 0, NULL, new IntlGregorianCalendar('Europe/Lisbon'));
echo $df->format($ts), "\n";
$df = new IntlDateFormatter('es_ES', 0, 0, 'Europe/Amsterdam', 0);
echo $df->format($ts), "\n";
--EXPECTF--
sábado, 31 de diciembre de 2011, 23:00:00 (hora estándar de las Azores)
domingo, 1 de enero de 2012, 1:00:00 (hora estándar de Europa central)
domingo, 1 de enero de 2012, 0:00:00 (hora estándar de Europa occidental)
sábado, 31 de diciembre de 2011, 19:00:00 (hora estándar oriental)
domingo, 1 de enero de 2012, 1:00:00 (hora estándar de Europa central)
domingo, 1 de enero de 2012, 0:00:00 (hora estándar de Europa occidental)
domingo, 1 de enero de 2012, 1:00:00 (hora estándar de Europa central)

View File

@ -1,8 +1,9 @@
--TEST--
numfmt_format() icu >= 53.1
numfmt_format() icu >= 53.1 && icu < 54.1
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
<?php if (version_compare(INTL_ICU_VERSION, '53.1') < 0) die('skip for ICU >= 53.1'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '54.1') >= 0) die('skip for ICU < 54.1'); ?>
--FILE--
<?php

View File

@ -0,0 +1,130 @@
--TEST--
numfmt_format() icu >= 54.1
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
<?php if (version_compare(INTL_ICU_VERSION, '54.1') < 0) die('skip for ICU >= 54.1'); ?>
--FILE--
<?php
/*
* Format a number using misc locales/patterns.
*/
/*
* TODO: doesn't pass on ICU 3.6 because 'ru' and 'de' locales changed
* currency and percent formatting.
*/
function ut_main()
{
$styles = array(
NumberFormatter::PATTERN_DECIMAL => '##.#####################',
NumberFormatter::DECIMAL => '',
NumberFormatter::CURRENCY => '',
NumberFormatter::PERCENT => '',
NumberFormatter::SCIENTIFIC => '',
NumberFormatter::SPELLOUT => '@@@@@@@',
NumberFormatter::ORDINAL => '',
NumberFormatter::DURATION => '',
NumberFormatter::PATTERN_RULEBASED => '#####.###',
1234999, // bad one
);
$integer = array(
NumberFormatter::ORDINAL => '',
NumberFormatter::DURATION => '',
);
$locales = array(
'en_US',
'ru_UA',
'de',
'fr',
'en_UK'
);
$str_res = '';
$number = 1234567.891234567890000;
foreach( $locales as $locale )
{
$str_res .= "\nLocale is: $locale\n";
foreach( $styles as $style => $pattern )
{
$fmt = ut_nfmt_create( $locale, $style, $pattern );
if(!$fmt) {
$str_res .= "Bad formatter!\n";
continue;
}
$str_res .= dump( isset($integer[$style])?ut_nfmt_format( $fmt, $number, NumberFormatter::TYPE_INT32):ut_nfmt_format( $fmt, $number ) ) . "\n";
}
}
return $str_res;
}
include_once( 'ut_common.inc' );
// Run the test
ut_run();
?>
--EXPECTREGEX--
Locale is: en_US
'1234567.89123457'
'1,234,567.891'
'\$1,234,567.89'
'123,456,789%'
'1.23456789123457E6'
'one million,? two hundred (and )?thirty-four thousand,? five hundred (and )?sixty-seven point eight nine one two three four five seven'
'1,234,567(th|ᵗʰ)'
'342:56:07'
'#####.###'
'USD1,234,567.89'
Locale is: ru_UA
'1234567,89123457'
'1 234 567,891'
'1 234 567,89 ?(грн\.|₴)'
'123 456 789 ?%'
'1,23456789123457E6'
'один миллион двести тридцать четыре тысячи пятьсот шестьдесят семь запятая восемь девять один два три четыре пять семь'
'1 234 567.?'
'1 234 567'
'#####.###'
'1 234 567,89 UAH'
Locale is: de
'1234567,89123457'
'1.234.567,891'
'(¤ )?1.234.567,89( ¤)?'
'123\.456\.789 %'
'1,23456789123457E6'
'eine Million zwei­hundert­vier­und­dreißig­tausend­fünf­hundert­sieben­und­sechzig Komma acht neun eins zwei drei vier fünf sieben'
'1.234.567.?'
'1.234.567'
'#####.###'
'1.234.567,89 ¤¤'
Locale is: fr
'1234567,89123457'
'1 234 567,891'
'1 234 567,89 ¤'
'123 456 789 ?%'
'1,23456789123457E6'
'un million deux cent trente-quatre mille cinq cent soixante-sept virgule huit neuf un deux trois quatre cinq sept'
'1 234 567e'
'1 234 567'
'#####.###'
'1 234 567,89 ¤¤'
Locale is: en_UK
'1234567.89123457'
'1,234,567.891'
'¤1,234,567.89'
'123,456,789%'
'1.23456789123457E6'
'one million,? two hundred (and )?thirty-four thousand,? five hundred (and )?sixty-seven point eight nine one two three four five seven'
'1,234,567(th|ᵗʰ)'
'342:56:07'
'#####.###'
'¤¤1,234,567.89'

View File

@ -4,6 +4,7 @@ MessageFormat accepts IntlCalendar args
<?php
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '52.1') < 0) die('skip for ICU >= 52.1'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '54.1') >= 0) die('skip for ICU < 54.1'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);

View File

@ -0,0 +1,30 @@
--TEST--
MessageFormat accepts IntlCalendar args
--SKIPIF--
<?php
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '54.1') < 0) die('skip for ICU >= 54.1'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
//ini_set("intl.default_locale", "nl");
ini_set('date.timezone', 'Europe/Lisbon');
$cal = new IntlGregorianCalendar(2012,04,17,17,35,36);
$msgf = new MessageFormatter('pt_PT', '{0,date,full} {0,time,h:m:s a V}');
echo $msgf->format(array($cal)), "\n";
//NOT FIXED:
/*$msgf = new MessageFormatter('en_US',
'{1, select, date {{0,date,full}} other {{0,time,h:m:s a V}}}');
echo "msgf2: ", $msgf->format(array($time, 'date')), " ",
$msgf->format(array($time, 'time')), "\n";
*/
?>
==DONE==
--EXPECT--
quinta-feira, 17 de maio de 2012 5:35:36 da tarde ptlis
==DONE==