]> granicus.if.org Git - php/commitdiff
Fixed bug #69398 IntlDateFormatter formatObject returns wrong value when time style...
authorMic <lenhatanh86@gmail.com>
Thu, 2 Jun 2016 20:37:44 +0000 (22:37 +0200)
committerAnatol Belski <ab@php.net>
Thu, 2 Jun 2016 20:40:27 +0000 (22:40 +0200)
ext/intl/dateformat/dateformat_format_object.cpp
ext/intl/tests/bug69398.phpt [new file with mode: 0644]

index accb27e63d7bc35efc0d1f5779e6aec9c4e87b71..e96ebe8243ab382c601926c5b1ea8e4e5edcc42b 100644 (file)
@@ -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)) {
diff --git a/ext/intl/tests/bug69398.phpt b/ext/intl/tests/bug69398.phpt
new file mode 100644 (file)
index 0000000..ea7dbd5
--- /dev/null
@@ -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==
+
+