Skip to content

Commit

Permalink
Fixed bug #69398 IntlDateFormatter formatObject returns wrong value w…
Browse files Browse the repository at this point in the history
…hen time style is NONE
  • Loading branch information
micti authored and weltling committed Jun 2, 2016
1 parent 527ddac commit 0112b64
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ext/intl/dateformat/dateformat_format_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ U_CFUNC PHP_FUNCTION(datefmt_format_object)
}

//there's no support for relative time in ICU yet
timeStyle = (DateFormat::EStyle)(timeStyle & ~DateFormat::kRelative);
if (timeStyle != DateFormat::NONE) {
timeStyle = (DateFormat::EStyle)(timeStyle & ~DateFormat::kRelative);
}

zend_class_entry *instance_ce = Z_OBJCE_P(object);
if (instanceof_function(instance_ce, Calendar_ce_ptr)) {
Expand Down
22 changes: 22 additions & 0 deletions ext/intl/tests/bug69398.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--TEST--
IntlDateFormatter::formatObject(): returns wrong value when time style is NONE.
--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
$date = IntlCalendar::createInstance('Asia/Ho_Chi_Minh');
$date->setTime($millitimestamp);
echo IntlDateFormatter::formatObject($date, array(IntlDateFormatter::SHORT, IntlDateFormatter::NONE), 'vi_VN'), "\n";
echo IntlDateFormatter::formatObject ($date, array(IntlDateFormatter::SHORT, IntlDateFormatter::NONE), 'ko_KR'), "\n";
?>
==DONE==

--EXPECTF--
04/04/2015
15. 4. 4.
==DONE==


0 comments on commit 0112b64

Please sign in to comment.