From d344313ffeb42947c0d4f68eed446930ff2c7359 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Fri, 6 Dec 2019 12:41:41 +0100 Subject: [PATCH] Fix #78912: INTL Support for accounting format We provide `NumberFormatter::CURRENCY_ACCOUNTING` to wrap `UNUM_CURRENCY_ACCOUNTING `[1]. [1] --- ext/intl/formatter/formatter.c | 4 +++- ext/intl/tests/bug78912.phpt | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 ext/intl/tests/bug78912.phpt diff --git a/ext/intl/formatter/formatter.c b/ext/intl/formatter/formatter.c index 98d767c465ac7..2c70f10fabfc7 100644 --- a/ext/intl/formatter/formatter.c +++ b/ext/intl/formatter/formatter.c @@ -49,7 +49,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 0000000000000..69d370ae0fff1 --- /dev/null +++ b/ext/intl/tests/bug78912.phpt @@ -0,0 +1,14 @@ +--TEST-- +Request #78912 (INTL Support for accounting format) +--SKIPIF-- += 53.0'); +?> +--FILE-- +formatCurrency(-12345.67, 'USD')); +?> +--EXPECT-- +string(12) "($12,345.67)"