mirror of
https://github.com/php/php-src.git
synced 2024-09-22 18:37:25 +00:00
527ddacd20
Relying on invariant strings is a mistake. Not only UTF-8, but also many charsets are not single byte. Actual date formats can be mixed with arbitrary strings, and this can bring erroneous results in the out. Thus, instead it is more convenient to say, that a format string can consist either on UTF-8 or on pure ASCII as its subset. This is what is currently being done in other classes like Formatter, etc. as well.
25 lines
781 B
PHP
25 lines
781 B
PHP
--TEST--
|
|
IntlDateFormatter::formatObject(): returns wrong utf8 value when $format param is utf8 string pattern.
|
|
--SKIPIF--
|
|
<?php
|
|
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
|
|
<?php if (version_compare(INTL_ICU_VERSION, '50.1.2') < 0) die('skip for ICU >= 51.1.2'); ?>
|
|
--FILE--
|
|
<?php
|
|
$millitimestamp = 1428133423941.0; // 14:43:43 April 04 2015
|
|
$pattern1 = '\'tháng\' MM, y'; // yMM format for Vietnamese
|
|
$pattern2 = 'y년 MMM'; // yMM format for Korean
|
|
$date = IntlCalendar::createInstance('Asia/Ho_Chi_Minh');
|
|
$date->setTime($millitimestamp);
|
|
echo IntlDateFormatter::formatObject($date, $pattern1, 'vi_VN'), "\n";
|
|
echo IntlDateFormatter::formatObject ($date, $pattern2, 'ko_KR'), "\n";
|
|
?>
|
|
==DONE==
|
|
|
|
--EXPECTF--
|
|
tháng 04, 2015
|
|
2015년 4월
|
|
==DONE==
|
|
|
|
|