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?

Comments

liquidcms’s picture

StatusFileSize
new1.43 KB

and the trivial patch in case this is considered a bug

liquidcms’s picture

Status: Active » Needs review
pobster’s picture

I 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

liquidcms’s picture

good to know.. thanks.

amateescu’s picture

StatusFileSize
new693 bytes

Corrected patch for this issue.

amateescu’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.