summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2019-12-06 12:41:41 +0100
committerChristoph M. Becker <cmbecker69@gmx.de>2019-12-09 16:34:56 +0100
commit505cc77cbeb8a43dab446ecba0c867c453588a52 (patch)
tree8bec032e90d8c87d328b0a2fe09201eb24b38ffe
parent8d36d79d579937d142d6cd79afb0a096f91db8e6 (diff)
downloadphp-git-505cc77cbeb8a43dab446ecba0c867c453588a52.tar.gz
Fix #78912: INTL Support for accounting format
We provide `NumberFormatter::CURRENCY_ACCOUNTING` to wrap `UNUM_CURRENCY_ACCOUNTING `[1]. [1] <https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/unum_8h.html#a4eb4d3ff13bd506e7078b2be4052266dae97cdd7ed612d07d251021c076efb1c5>
-rw-r--r--NEWS3
-rw-r--r--ext/intl/formatter/formatter.c4
-rw-r--r--ext/intl/tests/bug78912.phpt14
3 files changed, 20 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index afa5823d32..afe928926f 100644
--- a/NEWS
+++ b/NEWS
@@ -27,6 +27,9 @@ PHP NEWS
. Fixed bug #78916 (php-fpm 7.4.0 don't send mail via mail()).
(Jakub Zelenka)
+- Intl:
+ . Implemented FR #78912 (INTL Support for accounting format). (cmb)
+
- Mysqlnd:
. Fixed bug #78823 (ZLIB_LIBS not added to EXTRA_LIBS). (Arjen de Korte)
diff --git a/ext/intl/formatter/formatter.c b/ext/intl/formatter/formatter.c
index 0ccd4b5cbe..98e8e4677a 100644
--- a/ext/intl/formatter/formatter.c
+++ b/ext/intl/formatter/formatter.c
@@ -51,7 +51,9 @@ void formatter_register_constants( INIT_FUNC_ARGS )
FORMATTER_EXPOSE_CLASS_CONST( DURATION );
FORMATTER_EXPOSE_CLASS_CONST( PATTERN_RULEBASED );
FORMATTER_EXPOSE_CLASS_CONST( IGNORE );
-
+#if U_ICU_VERSION_MAJOR_NUM >= 53
+ FORMATTER_EXPOSE_CLASS_CONST( CURRENCY_ACCOUNTING );
+#endif
FORMATTER_EXPOSE_CUSTOM_CLASS_CONST( "DEFAULT_STYLE", UNUM_DEFAULT );
/* UNumberFormatRoundingMode */
diff --git a/ext/intl/tests/bug78912.phpt b/ext/intl/tests/bug78912.phpt
new file mode 100644
index 0000000000..69d370ae0f
--- /dev/null
+++ b/ext/intl/tests/bug78912.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Request #78912 (INTL Support for accounting format)
+--SKIPIF--
+<?php
+if (!extension_loaded('intl')) die('skip intl extension not available');
+if (version_compare(INTL_ICU_VERSION, '53.0') < 0) die('skip for ICU >= 53.0');
+?>
+--FILE--
+<?php
+$nf = new NumberFormatter('en_US', NumberFormatter::CURRENCY_ACCOUNTING);
+var_dump($nf->formatCurrency(-12345.67, 'USD'));
+?>
+--EXPECT--
+string(12) "($12,345.67)"