|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
[2016-06-02 20:45 UTC] ab@php.net
[2016-06-02 20:45 UTC] ab@php.net
-Status: Open
+Status: Closed
[2016-07-20 11:30 UTC] davey@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 07:00:01 2025 UTC |
Description: ------------ IntlDateFormatter::formatObject returns wrong utf8 value when $format param is utf8 string pattern. After check the "intl" source in github, I see maybe this bug comes from when processing input pattern in dateformat/dateformat_format_object.cpp file. in line 139 : convert_to_string_ex(format); and in line 192 : UnicodeString(Z_STRVAL_P(format), Z_STRLEN_P(format), Test script: --------------- <?php $millitimestamp = 1428133423941.0; // 14:43:43 April 04 2015 $fmt = new IntlDateFormatter('vi_VN',IntlDateFormatter::LONG, IntlDateFormatter::LONG, 'Asia/Ho_Chi_Minh'); $res3 = $fmt->format($millitimestamp / 1000); $fmt->setPattern('\'tháng\' MM, y'); //yMM $res1 = $fmt->format($millitimestamp / 1000); $date = IntlCalendar::createInstance('Asia/Ho_Chi_Minh'); $date->setTime($millitimestamp); $res2 = IntlDateFormatter::formatObject ($date, '\'tháng\' MM, y' /*yMM*/, 'vi_VN'); $res4 = IntlDateFormatter::formatObject ($date, [IntlDateFormatter::LONG, IntlDateFormatter::LONG], 'vi_VN'); echo $res1 . "\n" . $res2 . "\n"; echo ($res1 !== $res2) ? "Failed." : "Pass."; echo "\n"; echo $res3 . "\n" . $res4 . "\n"; echo ($res3 !== $res4) ? "Failed." : "Pass."; echo "\n"; Expected result: ---------------- tháng 04, 2015 tháng 04, 2015 Pass. 14:43:43 GMT+7 Ngày 04 tháng 04 năm 2015 14:43:43 GMT+7 Ngày 04 tháng 04 năm 2015 Pass. Actual result: -------------- tháng 04, 2015 tháng 04, 2015 Failed. 14:43:43 GMT+7 Ngày 04 tháng 04 năm 2015 14:43:43 GMT+7 Ngày 04 tháng 04 năm 2015 Pass.