Perhaps this is intentional; but i think a minor bug.
I was searching to find a theme_currency($amount, $currency) function where i could simply pass value and the currency and end up with a formatted value:
so theme_currency(18000, 'usd') ===> $18,000.00
but all i could find is theme_currency_api_amount($amount, $attributes) which requires me to pass a bunch of attributes. A little more digging and i found that this:
$c = currency_api_get_currencies();
$tc = $c['USD'];
would return a set of default attributes for my currency.. pretty cool.
so i could then simply do this:
echo theme_currency_api_amount(18000, $tc);
this works very nice except that 'decimals' doesnt get handled correctly.
currency_api_get_currencies() returns 'decimals' as the array key whereas
theme_currency_api_amount() uses 'decimal' as the array key.
Is this an intentional difference or a bug?
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 971124-fix_theme_defaults.patch | 693 bytes | amateescu |
| #1 | fix_theme_defaults.patch | 1.43 KB | liquidcms |
Comments
Comment #1
liquidcms commentedand the trivial patch in case this is considered a bug
Comment #2
liquidcms commentedComment #3
pobster commentedI also needed currency formatting and I decided that the configuration provided by this module wasn't sufficient for my needs... So, I wrote my own: http://drupal.org/project/format_currency
I did consider joining forces with this module, but instead decided to simply integrate with it as I consider that two smaller specialist modules are better than one behemoth module taking up space... I don't think it's down to a 'currency exchange' module to have to worry about currency formatting myself?
Pobster
Comment #4
liquidcms commentedgood to know.. thanks.
Comment #5
amateescu commentedCorrected patch for this issue.
Comment #6
amateescu commentedFixed with http://drupal.org/cvs?commit=467062