Note: This is taken from the Chicken Wiki, where a more recent version could be available.

Description

Perform currency convertion, using data from the XML feeds of the European Central Bank.

Author

Jean-Philippe Theberge

Version

1.0.0 (initial release)

Requires

Usage

(require-extension currency-converter)

Documentation

Procedure: (currency-convert FROM TO AMOUNT [#:table TABLE] [#:format? FORMAT?])

FROM and TO are symbols, AMOUNT is either a string or a number. TABLE is an alternate conversion to use, an alist of (SYMBOL . EURO-VALUE) FORMAT?, if #f, will not format the result as money (and thus return a string)

Variable: currency-converter-table

When #f (the default) the XML is retrieved and parsed from the bank at every call to currenncy-convert. When set, it's value is used as the conversion table.

Procedure: (currency-converter-table-initialize!)

Retrieve and parse current values from the bank and set currency-converter-table.

Available currencies

AUD

Australian dollar

BGN

Bulgarian lev

CAD

Canadian dollar

CHF

Swiss franc

CNY

Chinese yuan renminbi

CYP

Cyprus pound

CZK

Czech koruna

DKK

Danish krone

EEK

Estonian kroon

GBP

Pound sterling

HKD

Hong Kong dollar

HRK

Croatian kuna

HUF

Hungarian forint

IDR

Indonesian rupiah

ISK

Icelandic krona

JPY

Japanese yen

KRW

South Korean won

LTL

Lithuanian litas

LVL

Latvian lats

MTL

Maltese lira

MYR

Malaysian ringgit

NOK

Norwegian krone

NZD

New Zealand dollar

PHP

Philippine peso

PLN

Polish zloty

RON

New Romanian leu

RUB

Russian rouble

SEK

Swedish krona

SGD

Singapore dollar

SKK

Slovak koruna

THB

Thai baht

TRY

New Turkish lira

USD

US dollar

ZAR

South African rand

Examples

(currency-convert 'USD 'EUR 45.34)
=> "32.03"
(currency-convert 'USD 'EUR 45.34 #:format? #f)
=> 32.3003490774382
(currency-convert 'USD 'EUR 45.34 #:table '((EUR . 1)(USD . 34)))
=> "1.33"

Licence

Copyright 2007 Jean-Philippe Theberge

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

A full copy of the GPL license can be found at http://www.gnu.org/licenses/.