diff --git a/pynum2word/num2word_EN.py b/pynum2word/num2word_EN.py index ce0f151..5cc4e84 100644 --- a/pynum2word/num2word_EN.py +++ b/pynum2word/num2word_EN.py @@ -110,7 +110,7 @@ class Num2Word_EN(num2word_EU.Num2Word_EU): def to_currency(self, val, longval=True): return self.to_splitnum(val, hightxt="dollar/s", lowtxt="cent/s", - jointxt="and", longval=longval) + jointxt="and", longval=longval, cents = True) n2w = Num2Word_EN() diff --git a/pynum2word/num2word_EN_EUR.py b/pynum2word/num2word_EN_EUR.py index 73fcc40..15355e8 100644 --- a/pynum2word/num2word_EN_EUR.py +++ b/pynum2word/num2word_EN_EUR.py @@ -34,9 +34,9 @@ from num2word_EN import Num2Word_EN class Num2Word_EN_EUR(Num2Word_EN): - def to_currency(self, val, longval=True): + def to_currency(self, val, longval=True, cents=True, jointxt="and"): return self.to_splitnum(val, hightxt="euro/s", lowtxt="cents", - jointxt="and", longval=longval) + jointxt=jointxt, longval=longval, cents = cents) n2w = Num2Word_EN_EUR() diff --git a/pynum2word/num2word_LT.py b/pynum2word/num2word_LT.py index 17ade56..ed7f64a 100644 --- a/pynum2word/num2word_LT.py +++ b/pynum2word/num2word_LT.py @@ -191,7 +191,7 @@ def n2w(n): else: return int2word(int(n)) -def to_currency(n, currency='LTL'): +def to_currency(n, currency='LTL', cents = True): if type(n) == int: left = abs(n / 100) right = abs(n % 100) @@ -214,8 +214,13 @@ def to_currency(n, currency='LTL'): else: minus_str = "" + if cents: + cents_str = int2word(right) + else: + cents_str = "%02d" % right + return u'%s%s %s, %s %s' % (minus_str, int2word(left), pluralize(left, cr1), - int2word(right), pluralize(right, cr2)) + cents_str, pluralize(right, cr2)) to_card = n2w diff --git a/pynum2word/num2word_base.py b/pynum2word/num2word_base.py index 112c54e..3f55de5 100644 --- a/pynum2word/num2word_base.py +++ b/pynum2word/num2word_base.py @@ -206,7 +206,7 @@ class Num2Word_Base(object): #//CHECK: generalise? Any others like pounds/shillings/pence? def to_splitnum(self, val, hightxt="", lowtxt="", jointxt="", - divisor=100, longval=True): + divisor=100, longval=True, cents = True): out = [] try: high, low = val @@ -224,7 +224,10 @@ class Num2Word_Base(object): elif hightxt: out.append(hightxt) if low: - out.append(self.to_cardinal(low)) + if cents: + out.append(self.to_cardinal(low)) + else: + out.append("%02d" % low) if lowtxt and longval: out.append(self.title(self.inflect(low, lowtxt))) return " ".join(out) diff --git a/setup.py b/setup.py index 0aeb79f..41e5b3e 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ from setuptools import setup setup(name='pynum2word', - version=0.41, + version=0.42, description='Modules to convert numbers to words. Easily extensible.', author='Taro Ogawa ', author_email='tos@users.sourceforge.net',