mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Adapt ext/intl tests for ICU 72.1
This version replaces SPACEs before the meridian with NARROW NO-BREAK
SPACEs. Thus, we split the affected test cases as usual.
(cherry picked from commit 8dd51b462d
)
Fixes GH-10262.
This commit is contained in:
parent
4d4a53beee
commit
a9e7b90cc2
20 changed files with 681 additions and 0 deletions
|
@ -6,6 +6,7 @@ date.timezone=Atlantic/Azores
|
|||
intl
|
||||
--SKIPIF--
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '54.1') < 0) die('skip for ICU >= 54.1'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '72.1') >= 0) die('skip for ICU < 72.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
|
48
ext/intl/tests/dateformat_calendars_variant_icu72-1.phpt
Normal file
48
ext/intl/tests/dateformat_calendars_variant_icu72-1.phpt
Normal file
|
@ -0,0 +1,48 @@
|
|||
--TEST--
|
||||
IntlDateFormatter, calendars and time zone
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--EXTENSIONS--
|
||||
intl
|
||||
--SKIPIF--
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '72.1') < 0) die('skip for ICU >= 72.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(49) "Sunday, January 1, 2012 at 5:12:00 AM GMT+05:12"
|
||||
string(49) "Sunday, January 1, 2012 at 5:12:00 AM GMT+05:12"
|
||||
string(46) "Sunday, 6 Tevet 5772 at 5:12:00 AM GMT+05:12"
|
||||
|
||||
Fatal error: Uncaught IntlException: 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 %s:%d
|
||||
Stack trace:
|
||||
#0 %s(%d): IntlDateFormatter->__construct('en_US@calendar=...', 0, 0, 'GMT+05:12', -1)
|
||||
#1 {main}
|
||||
thrown in %s on line %d
|
|
@ -4,6 +4,8 @@ IntlDateFormatter::create() with default date and time types
|
|||
intl
|
||||
--INI--
|
||||
date.timezone=UTC
|
||||
--SKIPIF--
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '72.1') >= 0) die('skip for ICU < 72.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
|
26
ext/intl/tests/dateformat_create_default_icu72-1.phpt
Normal file
26
ext/intl/tests/dateformat_create_default_icu72-1.phpt
Normal file
|
@ -0,0 +1,26 @@
|
|||
--TEST--
|
||||
IntlDateFormatter::create() with default date and time types
|
||||
--EXTENSIONS--
|
||||
intl
|
||||
--INI--
|
||||
date.timezone=UTC
|
||||
--SKIPIF--
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '72.1') < 0) die('skip for ICU >= 72.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$ts = strtotime('2012-01-01 00:00:00 UTC');
|
||||
$fmt = IntlDateFormatter::create('en_US');
|
||||
echo $fmt->format($ts), "\n";
|
||||
|
||||
$fmt = new IntlDateFormatter('en_US');
|
||||
echo $fmt->format($ts), "\n";
|
||||
|
||||
$fmt = datefmt_create('en_US');
|
||||
echo $fmt->format($ts), "\n";
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
Sunday, January 1, 2012 at 12:00:00 AM Coordinated Universal Time
|
||||
Sunday, January 1, 2012 at 12:00:00 AM Coordinated Universal Time
|
||||
Sunday, January 1, 2012 at 12:00:00 AM Coordinated Universal Time
|
|
@ -4,6 +4,7 @@ IntlDateFormatter::formatObject(): IntlCalendar tests
|
|||
intl
|
||||
--SKIPIF--
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '55.1') < 0) die('skip for ICU >= 55.1'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '72.1') >= 0) die('skip for ICU < 72.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
--TEST--
|
||||
IntlDateFormatter::formatObject(): IntlCalendar tests
|
||||
--EXTENSIONS--
|
||||
intl
|
||||
--SKIPIF--
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '72.1') < 0) die('skip for ICU >= 72.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";
|
||||
|
||||
?>
|
||||
--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 Time
|
||||
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
|
|
@ -4,6 +4,7 @@ IntlDateFormatter::formatObject(): DateTime tests
|
|||
intl
|
||||
--SKIPIF--
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '55.1') < 0) die('skip for ICU >= 55.1'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '72.1') >= 0) die('skip for ICU < 72.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
--TEST--
|
||||
IntlDateFormatter::formatObject(): DateTime tests
|
||||
--EXTENSIONS--
|
||||
intl
|
||||
--SKIPIF--
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '72.1') < 0) die('skip for ICU < 72.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";
|
||||
|
||||
?>
|
||||
--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 Time
|
||||
Sun 2012-01-1 00,00,00.000 Portugal Time
|
||||
domingo, 1 de janeiro de 2012 às 05:00:00 GMT+03:00
|
|
@ -4,6 +4,7 @@ datefmt_format_code() and datefmt_parse_code()
|
|||
intl
|
||||
--SKIPIF--
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0) die('skip for ICU >= 51.2'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '72.1') >= 0) die('skip for ICU < 72.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
|
296
ext/intl/tests/dateformat_format_parse_version_icu72-1.phpt
Normal file
296
ext/intl/tests/dateformat_format_parse_version_icu72-1.phpt
Normal file
|
@ -0,0 +1,296 @@
|
|||
--TEST--
|
||||
datefmt_format_code() and datefmt_parse_code()
|
||||
--EXTENSIONS--
|
||||
intl
|
||||
--SKIPIF--
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '72.1') < 0) die('skip for ICU >= 72.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Test for the datefmt_format function
|
||||
*/
|
||||
|
||||
|
||||
function ut_main()
|
||||
{
|
||||
$timezone = 'GMT+05:00';
|
||||
|
||||
$locale_arr = array (
|
||||
'en_US'
|
||||
);
|
||||
|
||||
$datetype_arr = array (
|
||||
IntlDateFormatter::FULL,
|
||||
IntlDateFormatter::LONG,
|
||||
IntlDateFormatter::MEDIUM
|
||||
);
|
||||
|
||||
$res_str = '';
|
||||
|
||||
|
||||
$time_arr = array (
|
||||
0,
|
||||
-1200000,
|
||||
1200000,
|
||||
2200000000,
|
||||
-2200000000,
|
||||
90099999,
|
||||
3600,
|
||||
-3600
|
||||
);
|
||||
|
||||
$localtime_arr1 = array (
|
||||
'tm_sec' => 24 ,
|
||||
'tm_min' => 3,
|
||||
'tm_hour' => 19,
|
||||
'tm_mday' => 3,
|
||||
'tm_mon' => 3,
|
||||
'tm_year' => 105,
|
||||
);
|
||||
$localtime_arr2 = array (
|
||||
'tm_sec' => 21,
|
||||
'tm_min' => 5,
|
||||
'tm_hour' => 7,
|
||||
'tm_mday' => 13,
|
||||
'tm_mon' => 7,
|
||||
'tm_year' => 205,
|
||||
);
|
||||
$localtime_arr3 = array (
|
||||
'tm_sec' => 11,
|
||||
'tm_min' => 13,
|
||||
'tm_hour' => 0,
|
||||
'tm_mday' => 17,
|
||||
'tm_mon' => 11,
|
||||
'tm_year' => -5
|
||||
);
|
||||
|
||||
$localtime_arr = array (
|
||||
$localtime_arr1,
|
||||
$localtime_arr2,
|
||||
$localtime_arr3
|
||||
);
|
||||
|
||||
//Test format and parse with a timestamp : long
|
||||
foreach( $time_arr as $timestamp_entry){
|
||||
$res_str .= "\n------------\n";
|
||||
$res_str .= "\nInput timestamp is : $timestamp_entry";
|
||||
$res_str .= "\n------------\n";
|
||||
foreach( $locale_arr as $locale_entry ){
|
||||
foreach( $datetype_arr as $datetype_entry ) {
|
||||
$res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry ";
|
||||
$fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry,$timezone);
|
||||
$formatted = ut_datefmt_format( $fmt , $timestamp_entry);
|
||||
$res_str .= "\nFormatted timestamp is : $formatted";
|
||||
$parsed = ut_datefmt_parse( $fmt , $formatted);
|
||||
if( intl_get_error_code() == U_ZERO_ERROR){
|
||||
$res_str .= "\nParsed timestamp is : $parsed";
|
||||
}else{
|
||||
$res_str .= "\nError while parsing as: '".intl_get_error_message()."'";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Test format and parse with a localtime :array
|
||||
foreach( $localtime_arr as $localtime_entry){
|
||||
$res_str .= "\n------------\n";
|
||||
$res_str .= "\nInput localtime is : ";
|
||||
foreach( $localtime_entry as $key => $value){
|
||||
$res_str .= "$key : '$value' , ";
|
||||
}
|
||||
|
||||
$res_str .= "\n------------\n";
|
||||
foreach( $locale_arr as $locale_entry ){
|
||||
foreach( $datetype_arr as $datetype_entry ) {
|
||||
$res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry ";
|
||||
$fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry,$timezone);
|
||||
$formatted1 = ut_datefmt_format( $fmt , $localtime_entry);
|
||||
if( intl_get_error_code() == U_ZERO_ERROR){
|
||||
$res_str .= "\nFormatted localtime_array is : $formatted1";
|
||||
}else{
|
||||
$res_str .= "\nError while formatting as: '".intl_get_error_message()."'";
|
||||
}
|
||||
//Parsing
|
||||
$parsed_arr = ut_datefmt_localtime( $fmt, $formatted1 );
|
||||
|
||||
if( $parsed_arr){
|
||||
$res_str .= "\nParsed array is: ";
|
||||
foreach( $parsed_arr as $key => $value){
|
||||
$res_str .= "$key : '$value' , ";
|
||||
}
|
||||
}
|
||||
/*
|
||||
else{
|
||||
//$res_str .= "No values found from LocaleTime parsing.";
|
||||
$res_str .= "\tError : '".intl_get_error_message()."'";
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $res_str;
|
||||
|
||||
}
|
||||
|
||||
include_once( 'ut_common.inc' );
|
||||
|
||||
// Run the test
|
||||
ut_run();
|
||||
?>
|
||||
--EXPECT--
|
||||
------------
|
||||
|
||||
Input timestamp is : 0
|
||||
------------
|
||||
|
||||
IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
|
||||
Formatted timestamp is : Thursday, January 1, 1970 at 5:00:00 AM GMT+05:00
|
||||
Parsed timestamp is : 0
|
||||
IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
|
||||
Formatted timestamp is : January 1, 1970 at 5:00:00 AM GMT+5
|
||||
Parsed timestamp is : 0
|
||||
IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
|
||||
Formatted timestamp is : Jan 1, 1970, 5:00:00 AM
|
||||
Parsed timestamp is : 0
|
||||
------------
|
||||
|
||||
Input timestamp is : -1200000
|
||||
------------
|
||||
|
||||
IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
|
||||
Formatted timestamp is : Thursday, December 18, 1969 at 7:40:00 AM GMT+05:00
|
||||
Parsed timestamp is : -1200000
|
||||
IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
|
||||
Formatted timestamp is : December 18, 1969 at 7:40:00 AM GMT+5
|
||||
Parsed timestamp is : -1200000
|
||||
IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
|
||||
Formatted timestamp is : Dec 18, 1969, 7:40:00 AM
|
||||
Parsed timestamp is : -1200000
|
||||
------------
|
||||
|
||||
Input timestamp is : 1200000
|
||||
------------
|
||||
|
||||
IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
|
||||
Formatted timestamp is : Thursday, January 15, 1970 at 2:20:00 AM GMT+05:00
|
||||
Parsed timestamp is : 1200000
|
||||
IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
|
||||
Formatted timestamp is : January 15, 1970 at 2:20:00 AM GMT+5
|
||||
Parsed timestamp is : 1200000
|
||||
IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
|
||||
Formatted timestamp is : Jan 15, 1970, 2:20:00 AM
|
||||
Parsed timestamp is : 1200000
|
||||
------------
|
||||
|
||||
Input timestamp is : 2200000000
|
||||
------------
|
||||
|
||||
IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
|
||||
Formatted timestamp is : Monday, September 19, 2039 at 4:06:40 AM GMT+05:00
|
||||
Parsed timestamp is : 2200000000
|
||||
IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
|
||||
Formatted timestamp is : September 19, 2039 at 4:06:40 AM GMT+5
|
||||
Parsed timestamp is : 2200000000
|
||||
IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
|
||||
Formatted timestamp is : Sep 19, 2039, 4:06:40 AM
|
||||
Parsed timestamp is : 2200000000
|
||||
------------
|
||||
|
||||
Input timestamp is : -2200000000
|
||||
------------
|
||||
|
||||
IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
|
||||
Formatted timestamp is : Sunday, April 15, 1900 at 5:53:20 AM GMT+05:00
|
||||
Parsed timestamp is : -2200000000
|
||||
IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
|
||||
Formatted timestamp is : April 15, 1900 at 5:53:20 AM GMT+5
|
||||
Parsed timestamp is : -2200000000
|
||||
IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
|
||||
Formatted timestamp is : Apr 15, 1900, 5:53:20 AM
|
||||
Parsed timestamp is : -2200000000
|
||||
------------
|
||||
|
||||
Input timestamp is : 90099999
|
||||
------------
|
||||
|
||||
IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
|
||||
Formatted timestamp is : Thursday, November 9, 1972 at 12:46:39 AM GMT+05:00
|
||||
Parsed timestamp is : 90099999
|
||||
IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
|
||||
Formatted timestamp is : November 9, 1972 at 12:46:39 AM GMT+5
|
||||
Parsed timestamp is : 90099999
|
||||
IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
|
||||
Formatted timestamp is : Nov 9, 1972, 12:46:39 AM
|
||||
Parsed timestamp is : 90099999
|
||||
------------
|
||||
|
||||
Input timestamp is : 3600
|
||||
------------
|
||||
|
||||
IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
|
||||
Formatted timestamp is : Thursday, January 1, 1970 at 6:00:00 AM GMT+05:00
|
||||
Parsed timestamp is : 3600
|
||||
IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
|
||||
Formatted timestamp is : January 1, 1970 at 6:00:00 AM GMT+5
|
||||
Parsed timestamp is : 3600
|
||||
IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
|
||||
Formatted timestamp is : Jan 1, 1970, 6:00:00 AM
|
||||
Parsed timestamp is : 3600
|
||||
------------
|
||||
|
||||
Input timestamp is : -3600
|
||||
------------
|
||||
|
||||
IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
|
||||
Formatted timestamp is : Thursday, January 1, 1970 at 4:00:00 AM GMT+05:00
|
||||
Parsed timestamp is : -3600
|
||||
IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
|
||||
Formatted timestamp is : January 1, 1970 at 4:00:00 AM GMT+5
|
||||
Parsed timestamp is : -3600
|
||||
IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
|
||||
Formatted timestamp is : Jan 1, 1970, 4:00:00 AM
|
||||
Parsed timestamp is : -3600
|
||||
------------
|
||||
|
||||
Input localtime is : tm_sec : '24' , tm_min : '3' , tm_hour : '19' , tm_mday : '3' , tm_mon : '3' , tm_year : '105' ,
|
||||
------------
|
||||
|
||||
IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
|
||||
Formatted localtime_array is : Sunday, April 3, 2005 at 7:03:24 PM GMT+05:00
|
||||
Parsed array is: tm_sec : '24' , tm_min : '3' , tm_hour : '19' , tm_year : '105' , tm_mday : '3' , tm_wday : '0' , tm_yday : '93' , tm_mon : '3' , tm_isdst : '0' ,
|
||||
IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
|
||||
Formatted localtime_array is : April 3, 2005 at 7:03:24 PM GMT+5
|
||||
Parsed array is: tm_sec : '24' , tm_min : '3' , tm_hour : '19' , tm_year : '105' , tm_mday : '3' , tm_wday : '0' , tm_yday : '93' , tm_mon : '3' , tm_isdst : '0' ,
|
||||
IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
|
||||
Formatted localtime_array is : Apr 3, 2005, 7:03:24 PM
|
||||
Parsed array is: tm_sec : '24' , tm_min : '3' , tm_hour : '19' , tm_year : '105' , tm_mday : '3' , tm_wday : '0' , tm_yday : '93' , tm_mon : '3' , tm_isdst : '0' ,
|
||||
------------
|
||||
|
||||
Input localtime is : tm_sec : '21' , tm_min : '5' , tm_hour : '7' , tm_mday : '13' , tm_mon : '7' , tm_year : '205' ,
|
||||
------------
|
||||
|
||||
IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
|
||||
Formatted localtime_array is : Thursday, August 13, 2105 at 7:05:21 AM GMT+05:00
|
||||
Parsed array is: tm_sec : '21' , tm_min : '5' , tm_hour : '7' , tm_year : '205' , tm_mday : '13' , tm_wday : '4' , tm_yday : '225' , tm_mon : '7' , tm_isdst : '0' ,
|
||||
IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
|
||||
Formatted localtime_array is : August 13, 2105 at 7:05:21 AM GMT+5
|
||||
Parsed array is: tm_sec : '21' , tm_min : '5' , tm_hour : '7' , tm_year : '205' , tm_mday : '13' , tm_wday : '4' , tm_yday : '225' , tm_mon : '7' , tm_isdst : '0' ,
|
||||
IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
|
||||
Formatted localtime_array is : Aug 13, 2105, 7:05:21 AM
|
||||
Parsed array is: tm_sec : '21' , tm_min : '5' , tm_hour : '7' , tm_year : '205' , tm_mday : '13' , tm_wday : '4' , tm_yday : '225' , tm_mon : '7' , tm_isdst : '0' ,
|
||||
------------
|
||||
|
||||
Input localtime is : tm_sec : '11' , tm_min : '13' , tm_hour : '0' , tm_mday : '17' , tm_mon : '11' , tm_year : '-5' ,
|
||||
------------
|
||||
|
||||
IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0
|
||||
Formatted localtime_array is : Tuesday, December 17, 1895 at 12:13:11 AM GMT+05:00
|
||||
Parsed array is: tm_sec : '11' , tm_min : '13' , tm_hour : '0' , tm_year : '-5' , tm_mday : '17' , tm_wday : '2' , tm_yday : '351' , tm_mon : '11' , tm_isdst : '0' ,
|
||||
IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1
|
||||
Formatted localtime_array is : December 17, 1895 at 12:13:11 AM GMT+5
|
||||
Parsed array is: tm_sec : '11' , tm_min : '13' , tm_hour : '0' , tm_year : '-5' , tm_mday : '17' , tm_wday : '2' , tm_yday : '351' , tm_mon : '11' , tm_isdst : '0' ,
|
||||
IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2
|
||||
Formatted localtime_array is : Dec 17, 1895, 12:13:11 AM
|
||||
Parsed array is: tm_sec : '11' , tm_min : '13' , tm_hour : '0' , tm_year : '-5' , tm_mday : '17' , tm_wday : '2' , tm_yday : '351' , tm_mon : '11' , tm_isdst : '0' ,
|
|
@ -6,6 +6,7 @@ date.timezone=Atlantic/Azores
|
|||
intl
|
||||
--SKIPIF--
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0) die('skip for ICU >= 51.2'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '72.1') >= 0) die('skip for ICU < 72.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
|
85
ext/intl/tests/dateformat_set_timezone_id_icu72-1.phpt
Normal file
85
ext/intl/tests/dateformat_set_timezone_id_icu72-1.phpt
Normal file
|
@ -0,0 +1,85 @@
|
|||
--TEST--
|
||||
datefmt_set_timezone_id_code() icu >= 4.8
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--EXTENSIONS--
|
||||
intl
|
||||
--SKIPIF--
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '72.1') < 0) die('skip for ICU >= 72.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
/*
|
||||
* Test for the datefmt_set_timezone_id function
|
||||
*/
|
||||
|
||||
|
||||
function ut_main()
|
||||
{
|
||||
$timezone_id_arr = array (
|
||||
'America/New_York',
|
||||
'America/Los_Angeles',
|
||||
'America/Chicago',
|
||||
'CN'
|
||||
);
|
||||
$timestamp_entry = 0;
|
||||
|
||||
$res_str = '';
|
||||
|
||||
$fmt = ut_datefmt_create( "en_US", IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'US/Pacific' , IntlDateFormatter::GREGORIAN );
|
||||
$timezone_id = ut_datefmt_get_timezone_id( $fmt );
|
||||
$res_str .= "\nAfter creation of the dateformatter : timezone_id= $timezone_id\n";
|
||||
|
||||
foreach( $timezone_id_arr as $timezone_id_entry )
|
||||
{
|
||||
|
||||
$res_str .= "-----------";
|
||||
$res_str .= "\nTrying to set timezone_id= $timezone_id_entry";
|
||||
ut_datefmt_set_timezone_id( $fmt , $timezone_id_entry );
|
||||
$timezone_id = ut_datefmt_get_timezone_id( $fmt );
|
||||
$res_str .= "\nAfter call to set_timezone_id : timezone_id= $timezone_id";
|
||||
$formatted = ut_datefmt_format( $fmt, 0);
|
||||
$res_str .= "\nFormatting timestamp=0 resulted in $formatted";
|
||||
$formatted = ut_datefmt_format( $fmt, 3600);
|
||||
$res_str .= "\nFormatting timestamp=3600 resulted in $formatted";
|
||||
$res_str .= "\n";
|
||||
|
||||
}
|
||||
|
||||
return $res_str;
|
||||
|
||||
}
|
||||
|
||||
include_once( 'ut_common.inc' );
|
||||
|
||||
// Run the test
|
||||
ut_run();
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: IntlDateFormatter::setTimeZone(): datefmt_set_timezone: No such time zone: 'CN' in %sut_common.inc on line %d
|
||||
|
||||
Warning: datefmt_set_timezone(): datefmt_set_timezone: No such time zone: 'CN' in %sut_common.inc on line %d
|
||||
|
||||
After creation of the dateformatter : timezone_id= US/Pacific
|
||||
-----------
|
||||
Trying to set timezone_id= America/New_York
|
||||
After call to set_timezone_id : timezone_id= America/New_York
|
||||
Formatting timestamp=0 resulted in Wednesday, December 31, 1969 at 7:00:00 PM Eastern Standard Time
|
||||
Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 at 8:00:00 PM Eastern Standard Time
|
||||
-----------
|
||||
Trying to set timezone_id= America/Los_Angeles
|
||||
After call to set_timezone_id : timezone_id= America/Los_Angeles
|
||||
Formatting timestamp=0 resulted in Wednesday, December 31, 1969 at 4:00:00 PM Pacific Standard Time
|
||||
Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 at 5:00:00 PM Pacific Standard Time
|
||||
-----------
|
||||
Trying to set timezone_id= America/Chicago
|
||||
After call to set_timezone_id : timezone_id= America/Chicago
|
||||
Formatting timestamp=0 resulted in Wednesday, December 31, 1969 at 6:00:00 PM Central Standard Time
|
||||
Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 at 7:00:00 PM Central Standard Time
|
||||
-----------
|
||||
Trying to set timezone_id= CN
|
||||
After call to set_timezone_id : timezone_id= America/Chicago
|
||||
Formatting timestamp=0 resulted in Wednesday, December 31, 1969 at 6:00:00 PM Central Standard Time
|
||||
Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 at 7:00:00 PM Central Standard Time
|
|
@ -2,6 +2,8 @@
|
|||
IntlDatePatternGenerator::getBestPattern()
|
||||
--EXTENSIONS--
|
||||
intl
|
||||
--SKIPIF--
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '72.1') >= 0) die('skip for ICU < 72.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
--TEST--
|
||||
IntlDatePatternGenerator::getBestPattern()
|
||||
--EXTENSIONS--
|
||||
intl
|
||||
--SKIPIF--
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '72.1') < 0) die('skip for ICU >= 72.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
ini_set("intl.default_locale", "en_US");
|
||||
|
||||
$dtpg = new IntlDatePatternGenerator();
|
||||
$dtpg2 = new IntlDatePatternGenerator("de_DE");
|
||||
$dtpg3 = IntlDatePatternGenerator::create();
|
||||
$dtpg4 = IntlDatePatternGenerator::create("de_DE");
|
||||
|
||||
echo $dtpg->getBestPattern("jjmm"), "\n";
|
||||
echo $dtpg2->getBestPattern("jjmm"), "\n";
|
||||
echo $dtpg3->getBestPattern("YYYYMMMdd"), "\n";
|
||||
echo $dtpg4->getBestPattern("YYYYMMMdd"), "\n";
|
||||
|
||||
echo $dtpg->getBestPattern(""), "\n";
|
||||
|
||||
try {
|
||||
$dtpg->getBestPattern();
|
||||
} catch(\ArgumentCountError $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
h:mm a
|
||||
HH:mm
|
||||
MMM dd, YYYY
|
||||
dd. MMM YYYY
|
||||
|
||||
IntlDatePatternGenerator::getBestPattern() expects exactly 1 argument, 0 given
|
|
@ -4,6 +4,8 @@ MessageFormatter::format(): DateTime accepted to format dates and times
|
|||
date.timezone=Atlantic/Azores
|
||||
--EXTENSIONS--
|
||||
intl
|
||||
--SKIPIF--
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '72.1') >= 0) die('skip for ICU < 72.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
|
29
ext/intl/tests/msgfmt_format_datetime_icu72-1.phpt
Normal file
29
ext/intl/tests/msgfmt_format_datetime_icu72-1.phpt
Normal file
|
@ -0,0 +1,29 @@
|
|||
--TEST--
|
||||
MessageFormatter::format(): DateTime accepted to format dates and times
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--EXTENSIONS--
|
||||
intl
|
||||
--SKIPIF--
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '72.1') < 0) die('skip for ICU >= 72.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
//ini_set("intl.default_locale", "nl");
|
||||
|
||||
$fmt = <<<EOD
|
||||
{0,date} {0,time}
|
||||
EOD;
|
||||
|
||||
$dt = new DateTime("2012-05-06 18:00:42", new DateTimeZone("Europe/Lisbon"));
|
||||
$dti = new DateTimeImmutable("2012-05-06 18:00:42", new DateTimeZone("Europe/Lisbon"));
|
||||
|
||||
$mf = new MessageFormatter('en_US', $fmt);
|
||||
|
||||
var_dump($mf->format(array($dt)));
|
||||
var_dump($mf->format(array($dti)));
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
string(24) "May 6, 2012 5:00:42 PM"
|
||||
string(24) "May 6, 2012 5:00:42 PM"
|
|
@ -4,6 +4,8 @@ MessageFormatter::format(): simple types handling with numeric strings
|
|||
date.timezone=Atlantic/Azores
|
||||
--EXTENSIONS--
|
||||
intl
|
||||
--SKIPIF--
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '72.1') >= 0) die('skip for ICU < 72.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
--TEST--
|
||||
MessageFormatter::format(): simple types handling with numeric strings
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--EXTENSIONS--
|
||||
intl
|
||||
--SKIPIF--
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '72.1') < 0) die('skip for ICU >= 72.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
//ini_set("intl.default_locale", "nl");
|
||||
|
||||
$mf = new MessageFormatter('en_US',"
|
||||
none {a}
|
||||
number {b,number}
|
||||
number integer {c,number,integer}
|
||||
number currency {d,number,currency}
|
||||
number percent {e,number,percent}
|
||||
date {f,date}
|
||||
time {g,time}
|
||||
spellout {h,spellout}
|
||||
ordinal {i,ordinal}
|
||||
duration {j,duration}
|
||||
");
|
||||
|
||||
$ex = "1336317965.5 str";
|
||||
var_dump($mf->format(array(
|
||||
'a' => $ex,
|
||||
'b' => $ex,
|
||||
'c' => $ex,
|
||||
'd' => $ex,
|
||||
'e' => $ex,
|
||||
'f' => " 1336317965.5",
|
||||
'g' => " 1336317965.5",
|
||||
'h' => $ex,
|
||||
'i' => $ex,
|
||||
'j' => $ex,
|
||||
)));
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
string(%d) "
|
||||
none 1336317965.5 str
|
||||
number 1,336,317,965.5
|
||||
number integer 1,336,317,965
|
||||
number currency $1,336,317,965.50
|
||||
number percent 133,631,796,550%
|
||||
date May %d, 2012
|
||||
time 3:26:05 PM
|
||||
spellout one billion three hundred thirty-six million three hundred seventeen thousand nine hundred sixty-five point five
|
||||
ordinal 1,336,317,966th
|
||||
duration 371,199:26:06
|
||||
"
|
|
@ -6,6 +6,7 @@ date.timezone=Atlantic/Azores
|
|||
intl
|
||||
--SKIPIF--
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0) die('skip for ICU >= 51.2'); ?>
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '72.1') >= 0) die('skip for ICU < 72.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
--TEST--
|
||||
ResourceBundle constructor bundle accepts NULL for first two arguments
|
||||
--INI--
|
||||
date.timezone=Atlantic/Azores
|
||||
--EXTENSIONS--
|
||||
intl
|
||||
--SKIPIF--
|
||||
<?php if (version_compare(INTL_ICU_VERSION, '72.1') < 0) die('skip for ICU >= 72.1'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("intl.error_level", E_WARNING);
|
||||
|
||||
$r = new ResourceBundle('en_US', NULL);
|
||||
$c = $r->get('calendar')->get('gregorian')->get('DateTimePatterns')->get(0);
|
||||
var_dump($c);
|
||||
|
||||
ini_set('intl.default_locale', 'pt_PT');
|
||||
$r = new ResourceBundle(NULL, NULL);
|
||||
$c = $r->get('calendar')->get('gregorian')->get('DateTimePatterns')->get(0);
|
||||
var_dump($c);
|
||||
?>
|
||||
--EXPECT--
|
||||
string(16) "h:mm:ss a zzzz"
|
||||
string(13) "HH:mm:ss zzzz"
|
Loading…
Add table
Add a link
Reference in a new issue