Source (Text):
conversion = {
'be' : [40.3399, 1],
'de' : [1.95583, 100],
'gr' : [340.750, 1],
'es' : [166.386, 1],
'fr' : [6.55957, 100],
'ie' : [0.787564, 100],
'it' : [1936.27, 1],
'lu' : [40.3399, 1],
'nl' : [2.20371, 100],
'at' : [13.7603, 100],
'pt' : [200.482, 1],
'fi' : [5.94573, 100]
}
am =float(amount)
a = conversion[cc]
if dir=='to':
z1 = am/a[0]
return round(z1*100)/100
else:
p1 = am*a[0]
if a[1] == 1:
return int(round(p1*a[1])/a[1])
return round(p1*a[1])/a[1]
|
Explanation:
Create a 'euros' script, with attributes like:
amount=1, cc='es', dir='.'
Then in DTML you can call it like
<dtml-var "euros(amount='5', cc='nl', dir='to')">
This converts that amount of Netherland Guilders into Euros.
<dtml-var "euros(amount='5', cc='nl')">
With no 'dir' argument, this converts that amount of Euros into Netherland Guilders.
cc is the country-code. In the dictionary, I've chosen Internet country domain names as the clue. You may change that, of course.
See a demo convertor made with this at http://www.codesyntax.com/Euro
|