From a552ba224c38cca9a6474d2ca3a183291d72c3ec Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Mon, 25 Mar 2013 13:50:46 +0100 Subject: [PATCH] backport from bluebream version: number formatting with pattern --- util/format.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/util/format.py b/util/format.py index 7a7f780..2a0f911 100644 --- a/util/format.py +++ b/util/format.py @@ -50,10 +50,11 @@ def formatDate(dt=None, type='date', variant='medium', lang='de'): return fmt.format(dt or datetime.now()) -def formatNumber(num, type='decimal', lang='de'): +def formatNumber(num, type='decimal', lang='de', pattern=u'#,##0.00;-#,##0.00'): loc = locales.getLocale(lang) fmt = loc.numbers.getFormatter(type) - return fmt.format(num) + return fmt.format(num, pattern=pattern) + def toStr(value, encoding='UTF-8'):