zendframework/zf2 — pull request #2318 by bakura10 (2012-09-09 13:17:29+00:00)
Title: [WIP - help] Allow to remove decimals in CurrencyFormat

This PR adds an option to CurrencyFormat view helper to remove the two decimals number (I often need to simply prints the integer number).

HOWEVER it looks like NumberFormatter has a bug (I tried to read the unit tests of PHP and none of them covered the case, and I have not been able to find any help anywhere on the Internet).

The problem is that depending on the locale, it does not remove the decimals digits. This option sets the NumberFormatter::FRACTION_DIGITS attribute to 0, which should remove the decimals.

For instance, when setting the locale to "en_US", this $numberFormatter->formatCurrency('45', 'USD') prints "$45". However, when keeping the same locale (en-US) but chaning the currency to 'EUR', it prints "€45.00". At the same time, if I change the locale to "fr-FR", and prints a number with currency "EUR", it prints 45 €, and thus removing the decimals.

I've tried the money_format function of PHP and it does not suffer from this problem. So it really looks like Intl implementation is buggy, but at the same time, it works with some locales, and for other locales, it just does nothing. So we may merge (or not ?).

If anyone have some thoughts about it... (side note : rounding the number before formatting does nothing).